befly 3.66.0 → 3.67.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.
- package/apis/tongJi/dailyStats.js +3 -3
- package/checks/config.js +1 -28
- package/configs/beflyConfig.json +1 -2
- package/index.js +0 -29
- package/package.json +1 -1
|
@@ -86,7 +86,7 @@ function buildProductSummary(item, stats, todayCount) {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
async function
|
|
89
|
+
async function loadProjects(befly) {
|
|
90
90
|
if (!befly.mysql) {
|
|
91
91
|
return [];
|
|
92
92
|
}
|
|
@@ -102,9 +102,9 @@ async function loadProjectLists(befly) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
async function buildDailyStatsProducts(befly, history, dateStats) {
|
|
105
|
-
const
|
|
105
|
+
const projects = await loadProjects(befly);
|
|
106
106
|
const products = await Promise.all(
|
|
107
|
-
|
|
107
|
+
projects.map(async (item) => {
|
|
108
108
|
const stats = history[item.code] || { yesterday: 0, dayBeforeYesterday: 0, month: 0, lastMonth: 0 };
|
|
109
109
|
const todayCount = await getTodayCount(befly, dateStats.reportDate, item.code);
|
|
110
110
|
|
package/checks/config.js
CHANGED
|
@@ -12,31 +12,6 @@ const noTrimString = z.string().refine(isNoTrimStringAllowEmpty, "不允许首
|
|
|
12
12
|
const beflyModeSchema = z.union([z.literal("manual"), z.literal("auto")]);
|
|
13
13
|
const uploadExtensionListSchema = noTrimString.regex(/^\.[a-z0-9]+(?:,\.[a-z0-9]+)*$/);
|
|
14
14
|
const uploadMimeTypeListSchema = noTrimString.regex(/^[a-z0-9][a-z0-9.+-]*\/[a-z0-9][a-z0-9.+-]*(?:,[a-z0-9][a-z0-9.+-]*\/[a-z0-9][a-z0-9.+-]*)*$/);
|
|
15
|
-
const projectListCodeSchema = z.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/, "必须以字母开头,只允许字母、数字、短横线、下划线");
|
|
16
|
-
const projectListItemSchema = z
|
|
17
|
-
.object({
|
|
18
|
-
code: projectListCodeSchema,
|
|
19
|
-
name: noTrimString.min(1)
|
|
20
|
-
})
|
|
21
|
-
.strict();
|
|
22
|
-
const projectListsSchema = z.array(projectListItemSchema).superRefine((projectLists, ctx) => {
|
|
23
|
-
const codeSet = new Set();
|
|
24
|
-
|
|
25
|
-
for (let index = 0; index < projectLists.length; index += 1) {
|
|
26
|
-
const code = projectLists[index].code;
|
|
27
|
-
|
|
28
|
-
if (codeSet.has(code)) {
|
|
29
|
-
ctx.addIssue({
|
|
30
|
-
code: "custom",
|
|
31
|
-
message: `projectLists[${index}].code 重复`,
|
|
32
|
-
path: [index, "code"]
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
codeSet.add(code);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
15
|
const configSchema = z
|
|
41
16
|
.object({
|
|
42
17
|
runMode: z.enum(RUN_MODE_VALUES),
|
|
@@ -142,9 +117,7 @@ const configSchema = z
|
|
|
142
117
|
skipRoutes: z.array(noTrimString),
|
|
143
118
|
rules: z.array(z.object({}).passthrough())
|
|
144
119
|
})
|
|
145
|
-
.strict()
|
|
146
|
-
|
|
147
|
-
projectLists: projectListsSchema
|
|
120
|
+
.strict()
|
|
148
121
|
})
|
|
149
122
|
.strict();
|
|
150
123
|
|
package/configs/beflyConfig.json
CHANGED
package/index.js
CHANGED
|
@@ -55,34 +55,6 @@ function prefixMenuPaths(menus, prefix) {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function mergeProjectListsByCode(projectLists) {
|
|
59
|
-
if (!Array.isArray(projectLists)) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const itemMap = new Map();
|
|
64
|
-
|
|
65
|
-
for (const item of projectLists) {
|
|
66
|
-
const code = String(item?.code || "");
|
|
67
|
-
const name = String(item?.name || "");
|
|
68
|
-
|
|
69
|
-
if (!code) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (itemMap.has(code)) {
|
|
74
|
-
itemMap.delete(code);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
itemMap.set(code, {
|
|
78
|
-
code: code,
|
|
79
|
-
name: name
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return Array.from(itemMap.values());
|
|
84
|
-
}
|
|
85
|
-
|
|
86
58
|
async function ensureSyncPrerequisites(ctx) {
|
|
87
59
|
const missingCtxKeys = ["ctx.redis", "ctx.mysql", "ctx.cache"].filter((key) => !ctx[key.slice(4)]);
|
|
88
60
|
if (missingCtxKeys.length > 0) {
|
|
@@ -118,7 +90,6 @@ async function ensureSyncPrerequisites(ctx) {
|
|
|
118
90
|
export async function createBefly(config = {}, menus = []) {
|
|
119
91
|
const mergedConfig = deepMerge(beflyConfig, config);
|
|
120
92
|
const mergedMenus = deepMerge(prefixMenuPaths(beflyMenus, "core"), menus);
|
|
121
|
-
mergedConfig.projectLists = mergeProjectListsByCode(mergedConfig.projectLists);
|
|
122
93
|
|
|
123
94
|
Logger.configure({
|
|
124
95
|
runtimeEnv: mergedConfig.runMode,
|