befly 3.66.0 → 3.68.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.
@@ -86,7 +86,7 @@ function buildProductSummary(item, stats, todayCount) {
86
86
  };
87
87
  }
88
88
 
89
- async function loadProjectLists(befly) {
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 projectLists = await loadProjectLists(befly);
105
+ const projects = await loadProjects(befly);
106
106
  const products = await Promise.all(
107
- projectLists.map(async (item) => {
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
 
@@ -70,6 +70,5 @@
70
70
  "key": "ip",
71
71
  "skipRoutes": [],
72
72
  "rules": []
73
- },
74
- "projectLists": []
73
+ }
75
74
  }
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.66.0",
3
+ "version": "3.68.0",
4
4
  "gitHead": "49c39d36695036e85fc64083cc43c1652fff96cb",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
package/utils/is.js CHANGED
@@ -350,7 +350,7 @@ export function isEmpty(value) {
350
350
  * PM2 cluster 的实例 0 是主进程;未由 PM2 启动时视为主进程。
351
351
  */
352
352
  export function isPrimaryProcess(env) {
353
- return env.NODE_APP_INSTANCE === "0" || env.NODE_APP_INSTANCE === undefined;
353
+ return env.NODE_APP_INSTANCE === "0" || env.NODE_APP_INSTANCE === 0 || env.NODE_APP_INSTANCE === undefined;
354
354
  }
355
355
 
356
356
  export const isDirentDirectory = (parentDir, entry) => {