@kmkf-fe-packages/kmkf-work-order-service-component 2.2.5-beta.4 → 2.2.5-beta.41
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/esm/FlowTemplateDetailV2/components/FormRender/component-dependency-finder.d.ts +75 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/component-dependency-finder.js +328 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/index.js +396 -257
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/onBlur.d.ts +21 -7
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/onBlur.js +146 -28
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/skxOrderBack.d.ts +9 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/skxOrderBack.js +161 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/types.d.ts +41 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/types.js +1 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-finder.d.ts +61 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-finder.js +292 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-types.d.ts +65 -0
- package/dist/esm/FlowTemplateDetailV2/components/FormRender/value-mapping-types.js +1 -0
- package/dist/esm/FlowTemplateDetailV2/components/ShareLinkModal/index.d.ts +0 -1
- package/dist/esm/FlowTemplateDetailV2/components/ShareLinkModal/index.js +43 -33
- package/dist/esm/FlowTemplateDetailV2/components/ShareLinkModal/index.module.less +2 -2
- package/dist/esm/FlowTemplateDetailV2/index.js +42 -32
- package/dist/esm/FlowTemplateDetailV2/store/reducers.d.ts +2 -0
- package/dist/esm/FlowTemplateDetailV2/store/reducers.js +13 -7
- package/dist/esm/FlowTemplateDetailV2/store/selector.d.ts +1 -0
- package/dist/esm/FlowTemplateDetailV2/store/selector.js +3 -0
- package/dist/esm/common/utils/submitDataTransOldFormat.js +1 -1
- package/dist/esm/common/utils/tools.js +20 -12
- package/dist/esm/common/utils/transformWorkOrderData.js +1 -1
- package/dist/esm/model/flowTemplateDetail/api.js +2 -1
- package/dist/esm/model/flowTemplateDetail/types.d.ts +1 -0
- package/dist/esm/model/logicFlow/selector.d.ts +0 -3
- package/dist/esm/model/paymentWorkOrder/selector.d.ts +0 -9
- package/dist/esm/model/servers/request.js +1 -1
- package/dist/esm/model/singleShopWorkOrder/selector.d.ts +0 -5
- package/package.json +5 -5
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件显隐依赖关系查找器 - TypeScript ES Module版本
|
|
3
|
+
* 根据配置文件递归查找组件的所有依赖关系
|
|
4
|
+
*/
|
|
5
|
+
import type { Config, DependencyGraph, CircularDependency, DependencyLevels, ComponentStat, DependencyOptions, DependencyAnalysis } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* 查找组件的所有依赖关系(递归)
|
|
8
|
+
* @param componentKey - 要查找依赖的组件key
|
|
9
|
+
* @param config - 显隐配置对象
|
|
10
|
+
* @param visited - 已访问的组件集合,用于避免循环依赖
|
|
11
|
+
* @param dependencies - 依赖组件集合
|
|
12
|
+
* @param options - 查找选项
|
|
13
|
+
* @returns 所有依赖组件的key数组
|
|
14
|
+
*/
|
|
15
|
+
export declare function findAllDependencies(componentKey: string, config: Config, visited?: Set<string>, dependencies?: Set<string>, options?: DependencyOptions): string[];
|
|
16
|
+
/**
|
|
17
|
+
* 获取组件的直接依赖
|
|
18
|
+
* @param componentKey - 组件key
|
|
19
|
+
* @param config - 显隐配置对象
|
|
20
|
+
* @returns 直接依赖的组件key数组
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDirectDependencies(componentKey: string, config: Config): string[];
|
|
23
|
+
/**
|
|
24
|
+
* 构建整个依赖关系图
|
|
25
|
+
* @param config - 显隐配置对象
|
|
26
|
+
* @returns 依赖关系图,格式:{ componentKey: [依赖的组件数组] }
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildDependencyGraph(config: Config): DependencyGraph;
|
|
29
|
+
/**
|
|
30
|
+
* 检测循环依赖
|
|
31
|
+
* @param config - 显隐配置对象
|
|
32
|
+
* @returns 包含循环依赖的组件组
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectCircularDependencies(config: Config): CircularDependency[];
|
|
35
|
+
/**
|
|
36
|
+
* 打印依赖关系树
|
|
37
|
+
* @param componentKey - 组件key
|
|
38
|
+
* @param config - 显隐配置对象
|
|
39
|
+
* @param level - 缩进级别
|
|
40
|
+
* @param visited - 已访问的组件集合
|
|
41
|
+
*/
|
|
42
|
+
export declare function printDependencyTree(componentKey: string, config: Config, level?: number, visited?: Set<string>): void;
|
|
43
|
+
/**
|
|
44
|
+
* 获取组件的依赖层级
|
|
45
|
+
* @param componentKey - 组件key
|
|
46
|
+
* @param config - 显隐配置对象
|
|
47
|
+
* @returns 依赖层级对象
|
|
48
|
+
*/
|
|
49
|
+
export declare function getDependencyLevels(componentKey: string, config: Config): DependencyLevels;
|
|
50
|
+
/**
|
|
51
|
+
* 分析组件的完整依赖信息
|
|
52
|
+
* @param componentKey - 组件key
|
|
53
|
+
* @param config - 显隐配置对象
|
|
54
|
+
* @returns 完整的依赖分析结果
|
|
55
|
+
*/
|
|
56
|
+
export declare function analyzeDependency(componentKey: string, config: Config): DependencyAnalysis;
|
|
57
|
+
/**
|
|
58
|
+
* 获取依赖统计信息
|
|
59
|
+
* @param config - 显隐配置对象
|
|
60
|
+
* @param topN - 返回前N个结果
|
|
61
|
+
* @returns 组件统计信息数组
|
|
62
|
+
*/
|
|
63
|
+
export declare function getDependencyStats(config: Config, topN?: number): {
|
|
64
|
+
mostDependencies: ComponentStat[];
|
|
65
|
+
mostDependedOn: ComponentStat[];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* 验证配置文件格式
|
|
69
|
+
* @param config - 要验证的配置对象
|
|
70
|
+
* @returns 验证结果和错误信息
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateConfig(config: unknown): {
|
|
73
|
+
isValid: boolean;
|
|
74
|
+
errors: string[];
|
|
75
|
+
};
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
/**
|
|
13
|
+
* 组件显隐依赖关系查找器 - TypeScript ES Module版本
|
|
14
|
+
* 根据配置文件递归查找组件的所有依赖关系
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 查找组件的所有依赖关系(递归)
|
|
19
|
+
* @param componentKey - 要查找依赖的组件key
|
|
20
|
+
* @param config - 显隐配置对象
|
|
21
|
+
* @param visited - 已访问的组件集合,用于避免循环依赖
|
|
22
|
+
* @param dependencies - 依赖组件集合
|
|
23
|
+
* @param options - 查找选项
|
|
24
|
+
* @returns 所有依赖组件的key数组
|
|
25
|
+
*/
|
|
26
|
+
export function findAllDependencies(componentKey, config) {
|
|
27
|
+
var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
28
|
+
var dependencies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
|
|
29
|
+
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
30
|
+
var _options$maxDepth = options.maxDepth,
|
|
31
|
+
maxDepth = _options$maxDepth === void 0 ? Infinity : _options$maxDepth;
|
|
32
|
+
|
|
33
|
+
// 如果已经访问过这个组件,直接返回(避免循环依赖)
|
|
34
|
+
if (visited.has(componentKey)) {
|
|
35
|
+
return Array.from(dependencies);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 检查递归深度
|
|
39
|
+
if (visited.size >= maxDepth) {
|
|
40
|
+
return Array.from(dependencies);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 标记当前组件为已访问
|
|
44
|
+
visited.add(componentKey);
|
|
45
|
+
|
|
46
|
+
// 获取当前组件的配置
|
|
47
|
+
var componentConfig = config[componentKey];
|
|
48
|
+
|
|
49
|
+
// 如果组件不存在配置,返回当前依赖列表
|
|
50
|
+
if (!componentConfig || !Array.isArray(componentConfig)) {
|
|
51
|
+
return Array.from(dependencies);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 遍历组件的所有规则组
|
|
55
|
+
componentConfig.forEach(function (ruleGroup) {
|
|
56
|
+
if (ruleGroup.rules && Array.isArray(ruleGroup.rules)) {
|
|
57
|
+
// 遍历规则组中的所有规则
|
|
58
|
+
ruleGroup.rules.forEach(function (rule) {
|
|
59
|
+
if (rule.leftValue && typeof rule.leftValue === 'string') {
|
|
60
|
+
var dependencyKey = rule.leftValue;
|
|
61
|
+
|
|
62
|
+
// 添加直接依赖
|
|
63
|
+
dependencies.add(dependencyKey);
|
|
64
|
+
|
|
65
|
+
// 递归查找间接依赖
|
|
66
|
+
findAllDependencies(dependencyKey, config, visited, dependencies, options);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return Array.from(dependencies);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 获取组件的直接依赖
|
|
76
|
+
* @param componentKey - 组件key
|
|
77
|
+
* @param config - 显隐配置对象
|
|
78
|
+
* @returns 直接依赖的组件key数组
|
|
79
|
+
*/
|
|
80
|
+
export function getDirectDependencies(componentKey, config) {
|
|
81
|
+
var componentConfig = config[componentKey];
|
|
82
|
+
var dependencies = new Set();
|
|
83
|
+
if (!componentConfig || !Array.isArray(componentConfig)) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
componentConfig.forEach(function (ruleGroup) {
|
|
87
|
+
if (ruleGroup.rules && Array.isArray(ruleGroup.rules)) {
|
|
88
|
+
ruleGroup.rules.forEach(function (rule) {
|
|
89
|
+
if (rule.leftValue && typeof rule.leftValue === 'string') {
|
|
90
|
+
dependencies.add(rule.leftValue);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return Array.from(dependencies);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 构建整个依赖关系图
|
|
100
|
+
* @param config - 显隐配置对象
|
|
101
|
+
* @returns 依赖关系图,格式:{ componentKey: [依赖的组件数组] }
|
|
102
|
+
*/
|
|
103
|
+
export function buildDependencyGraph(config) {
|
|
104
|
+
var dependencyGraph = {};
|
|
105
|
+
Object.keys(config).forEach(function (componentKey) {
|
|
106
|
+
dependencyGraph[componentKey] = findAllDependencies(componentKey, config);
|
|
107
|
+
});
|
|
108
|
+
return dependencyGraph;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 检测循环依赖
|
|
113
|
+
* @param config - 显隐配置对象
|
|
114
|
+
* @returns 包含循环依赖的组件组
|
|
115
|
+
*/
|
|
116
|
+
export function detectCircularDependencies(config) {
|
|
117
|
+
var circularDeps = [];
|
|
118
|
+
var visiting = new Set();
|
|
119
|
+
var visited = new Set();
|
|
120
|
+
function dfs(componentKey) {
|
|
121
|
+
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
122
|
+
if (visiting.has(componentKey)) {
|
|
123
|
+
// 发现循环依赖
|
|
124
|
+
var cycleStart = path.indexOf(componentKey);
|
|
125
|
+
circularDeps.push(path.slice(cycleStart).concat(componentKey));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (visited.has(componentKey)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
visiting.add(componentKey);
|
|
132
|
+
path.push(componentKey);
|
|
133
|
+
var directDeps = getDirectDependencies(componentKey, config);
|
|
134
|
+
directDeps.forEach(function (dep) {
|
|
135
|
+
dfs(dep, _toConsumableArray(path));
|
|
136
|
+
});
|
|
137
|
+
visiting.delete(componentKey);
|
|
138
|
+
visited.add(componentKey);
|
|
139
|
+
}
|
|
140
|
+
Object.keys(config).forEach(function (componentKey) {
|
|
141
|
+
if (!visited.has(componentKey)) {
|
|
142
|
+
dfs(componentKey);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return circularDeps;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 打印依赖关系树
|
|
150
|
+
* @param componentKey - 组件key
|
|
151
|
+
* @param config - 显隐配置对象
|
|
152
|
+
* @param level - 缩进级别
|
|
153
|
+
* @param visited - 已访问的组件集合
|
|
154
|
+
*/
|
|
155
|
+
export function printDependencyTree(componentKey, config) {
|
|
156
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
157
|
+
var visited = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Set();
|
|
158
|
+
var indent = ' '.repeat(level);
|
|
159
|
+
console.log("".concat(indent).concat(componentKey));
|
|
160
|
+
if (visited.has(componentKey)) {
|
|
161
|
+
console.log("".concat(indent, " [\u5FAA\u73AF\u4F9D\u8D56]"));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
visited.add(componentKey);
|
|
165
|
+
var directDeps = getDirectDependencies(componentKey, config);
|
|
166
|
+
directDeps.forEach(function (dep) {
|
|
167
|
+
printDependencyTree(dep, config, level + 1, new Set(visited));
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 获取组件的依赖层级
|
|
173
|
+
* @param componentKey - 组件key
|
|
174
|
+
* @param config - 显隐配置对象
|
|
175
|
+
* @returns 依赖层级对象
|
|
176
|
+
*/
|
|
177
|
+
export function getDependencyLevels(componentKey, config) {
|
|
178
|
+
var levels = {};
|
|
179
|
+
var queue = [{
|
|
180
|
+
key: componentKey,
|
|
181
|
+
level: 0
|
|
182
|
+
}];
|
|
183
|
+
var visited = new Set();
|
|
184
|
+
var _loop = function _loop() {
|
|
185
|
+
var current = queue.shift();
|
|
186
|
+
if (!current) return "break";
|
|
187
|
+
var key = current.key,
|
|
188
|
+
level = current.level;
|
|
189
|
+
if (visited.has(key)) return "continue";
|
|
190
|
+
visited.add(key);
|
|
191
|
+
if (level > 0) {
|
|
192
|
+
// 不包含自己
|
|
193
|
+
if (!levels[level]) levels[level] = [];
|
|
194
|
+
levels[level].push(key);
|
|
195
|
+
}
|
|
196
|
+
var directDeps = getDirectDependencies(key, config);
|
|
197
|
+
directDeps.forEach(function (dep) {
|
|
198
|
+
if (!visited.has(dep)) {
|
|
199
|
+
queue.push({
|
|
200
|
+
key: dep,
|
|
201
|
+
level: level + 1
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
while (queue.length > 0) {
|
|
207
|
+
var _ret = _loop();
|
|
208
|
+
if (_ret === "break") break;
|
|
209
|
+
if (_ret === "continue") continue;
|
|
210
|
+
}
|
|
211
|
+
return levels;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 分析组件的完整依赖信息
|
|
216
|
+
* @param componentKey - 组件key
|
|
217
|
+
* @param config - 显隐配置对象
|
|
218
|
+
* @returns 完整的依赖分析结果
|
|
219
|
+
*/
|
|
220
|
+
export function analyzeDependency(componentKey, config) {
|
|
221
|
+
var directDependencies = getDirectDependencies(componentKey, config);
|
|
222
|
+
var allDependencies = findAllDependencies(componentKey, config);
|
|
223
|
+
var dependencyLevels = getDependencyLevels(componentKey, config);
|
|
224
|
+
|
|
225
|
+
// 检查是否有循环依赖
|
|
226
|
+
var circularDeps = detectCircularDependencies(config);
|
|
227
|
+
var hasCircularDependency = circularDeps.some(function (cycle) {
|
|
228
|
+
return cycle.includes(componentKey);
|
|
229
|
+
});
|
|
230
|
+
return {
|
|
231
|
+
componentKey: componentKey,
|
|
232
|
+
directDependencies: directDependencies,
|
|
233
|
+
allDependencies: allDependencies,
|
|
234
|
+
dependencyCount: allDependencies.length,
|
|
235
|
+
dependencyLevels: dependencyLevels,
|
|
236
|
+
hasCircularDependency: hasCircularDependency
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 获取依赖统计信息
|
|
242
|
+
* @param config - 显隐配置对象
|
|
243
|
+
* @param topN - 返回前N个结果
|
|
244
|
+
* @returns 组件统计信息数组
|
|
245
|
+
*/
|
|
246
|
+
export function getDependencyStats(config) {
|
|
247
|
+
var topN = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
248
|
+
var dependencyGraph = buildDependencyGraph(config);
|
|
249
|
+
|
|
250
|
+
// 统计依赖数量最多的组件
|
|
251
|
+
var mostDependencies = Object.entries(dependencyGraph).map(function (_ref) {
|
|
252
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
253
|
+
key = _ref2[0],
|
|
254
|
+
deps = _ref2[1];
|
|
255
|
+
return {
|
|
256
|
+
key: key,
|
|
257
|
+
count: deps.length
|
|
258
|
+
};
|
|
259
|
+
}).sort(function (a, b) {
|
|
260
|
+
return b.count - a.count;
|
|
261
|
+
}).slice(0, topN);
|
|
262
|
+
|
|
263
|
+
// 统计被依赖最多的组件
|
|
264
|
+
var dependedOnCount = {};
|
|
265
|
+
Object.values(dependencyGraph).forEach(function (deps) {
|
|
266
|
+
deps.forEach(function (dep) {
|
|
267
|
+
dependedOnCount[dep] = (dependedOnCount[dep] || 0) + 1;
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
var mostDependedOn = Object.entries(dependedOnCount).map(function (_ref3) {
|
|
271
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
272
|
+
key = _ref4[0],
|
|
273
|
+
count = _ref4[1];
|
|
274
|
+
return {
|
|
275
|
+
key: key,
|
|
276
|
+
count: count
|
|
277
|
+
};
|
|
278
|
+
}).sort(function (a, b) {
|
|
279
|
+
return b.count - a.count;
|
|
280
|
+
}).slice(0, topN);
|
|
281
|
+
return {
|
|
282
|
+
mostDependencies: mostDependencies,
|
|
283
|
+
mostDependedOn: mostDependedOn
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* 验证配置文件格式
|
|
289
|
+
* @param config - 要验证的配置对象
|
|
290
|
+
* @returns 验证结果和错误信息
|
|
291
|
+
*/
|
|
292
|
+
export function validateConfig(config) {
|
|
293
|
+
var errors = [];
|
|
294
|
+
if (!config || _typeof(config) !== 'object') {
|
|
295
|
+
errors.push('配置必须是一个对象');
|
|
296
|
+
return {
|
|
297
|
+
isValid: false,
|
|
298
|
+
errors: errors
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
var configObj = config;
|
|
302
|
+
Object.entries(configObj).forEach(function (_ref5) {
|
|
303
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
304
|
+
key = _ref6[0],
|
|
305
|
+
value = _ref6[1];
|
|
306
|
+
if (!Array.isArray(value)) {
|
|
307
|
+
errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u914D\u7F6E\u5FC5\u987B\u662F\u6570\u7EC4"));
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
value.forEach(function (ruleGroup, index) {
|
|
311
|
+
if (!ruleGroup || _typeof(ruleGroup) !== 'object') {
|
|
312
|
+
errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u89C4\u5219\u7EC4 ").concat(index, " \u5FC5\u987B\u662F\u5BF9\u8C61"));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
var group = ruleGroup;
|
|
316
|
+
if (!group.linkCondition || !['some', 'every'].includes(group.linkCondition)) {
|
|
317
|
+
errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u89C4\u5219\u7EC4 ").concat(index, " linkCondition \u5FC5\u987B\u662F 'some' \u6216 'every'"));
|
|
318
|
+
}
|
|
319
|
+
if (!Array.isArray(group.rules)) {
|
|
320
|
+
errors.push("\u7EC4\u4EF6 ".concat(key, " \u7684\u89C4\u5219\u7EC4 ").concat(index, " rules \u5FC5\u987B\u662F\u6570\u7EC4"));
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
return {
|
|
325
|
+
isValid: errors.length === 0,
|
|
326
|
+
errors: errors
|
|
327
|
+
};
|
|
328
|
+
}
|