befly 3.24.0 → 3.24.1

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/hooks/parser.js CHANGED
@@ -1,10 +1,6 @@
1
- // 外部依赖
2
- import { XMLParser } from "fast-xml-parser";
3
-
1
+ import { xmlParse } from "../plugins/xmlParse.js";
4
2
  import { ErrorResponse } from "../utils/response.js";
5
3
 
6
- const xmlParser = new XMLParser();
7
-
8
4
  /**
9
5
  * 请求参数解析钩子
10
6
  * - GET 请求:解析 URL 查询参数
@@ -37,7 +33,7 @@ export default {
37
33
  } else if (contentType.includes("application/xml") || contentType.includes("text/xml")) {
38
34
  // XML 格式
39
35
  const text = await ctx.req.text();
40
- const parsed = xmlParser.parse(text);
36
+ const parsed = xmlParse(text);
41
37
  // 提取根节点内容(如 xml),使 body 扁平化
42
38
  const rootKey = Object.keys(parsed)[0];
43
39
  const body = rootKey && typeof parsed[rootKey] === "object" ? parsed[rootKey] : parsed;
package/index.js CHANGED
@@ -32,7 +32,9 @@ import { scanSources } from "./utils/scanSources.js";
32
32
  import { isPrimaryProcess } from "./utils/is.js";
33
33
  import { deepMerge } from "./utils/deepMerge.js";
34
34
 
35
- export { syncDbApply as syncDb } from "./scripts/syncDb/index.js";
35
+ export { syncDb } from "./scripts/syncDb/index.js";
36
+ export { xmlParse } from "./plugins/xmlParse.js";
37
+ export { Logger };
36
38
 
37
39
  function prefixMenuPaths(menus, prefix) {
38
40
  return menus.map((menu) => {
@@ -267,5 +269,3 @@ export class Befly {
267
269
  }
268
270
  }
269
271
  }
270
-
271
- export { Logger };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.24.0",
4
- "gitHead": "976e70ee1f6f959e9def8189bd43ad4c0d454b7f",
3
+ "version": "3.24.1",
4
+ "gitHead": "5ec9cbeeba3aed39c52f227785c729eab34d7db5",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
7
7
  "keywords": [
@@ -0,0 +1,25 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+
3
+ import { isString } from "../utils/is.js";
4
+
5
+ const xmlParser = new XMLParser();
6
+
7
+ export function xmlParse(value) {
8
+ if (!isString(value) || value.length < 1) {
9
+ throw new Error("xmlParse 输入必须是非空字符串", {
10
+ cause: null,
11
+ code: "validation",
12
+ subsystem: "xml",
13
+ operation: "xmlParse"
14
+ });
15
+ }
16
+
17
+ return xmlParser.parse(value);
18
+ }
19
+
20
+ export default {
21
+ order: 4,
22
+ handler: () => {
23
+ return xmlParse;
24
+ }
25
+ };
@@ -6,7 +6,7 @@ import { applySyncDbDiff } from "./diff.js";
6
6
  import { prepareSyncDbBaseContext } from "./context.js";
7
7
  import { printSyncDbDiffSummary, printSyncDbProcessLog, writeSyncDbReport } from "./report.js";
8
8
 
9
- export async function syncDbApply(mysqlConfig) {
9
+ export async function syncDb(mysqlConfig) {
10
10
  const reportPath = resolve(join(process.cwd(), "db.sync.md"));
11
11
  try {
12
12
  printSyncDbProcessLog("开始执行应用");