bfi-cli 0.1.93 → 0.1.94

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +34 -2
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -8134,12 +8134,14 @@ const ALLOWED_FLAGS = {
8134
8134
  callstat: [
8135
8135
  ...F_ENV,
8136
8136
  ...F_RANGE,
8137
+ "--app",
8137
8138
  "--page",
8138
8139
  "--page-size"
8139
8140
  ],
8140
8141
  sqlstat: [
8141
8142
  ...F_ENV,
8142
8143
  ...F_RANGE,
8144
+ "--app",
8143
8145
  "--page",
8144
8146
  "--page-size"
8145
8147
  ],
@@ -8184,6 +8186,16 @@ const ALLOWED_FLAGS = {
8184
8186
  "--timeout"
8185
8187
  ]
8186
8188
  };
8189
+ const SUBCOMMAND_HINTS = {
8190
+ "db-tenant-locate": "租户定位在 db 命令组:bfi db tenant-locate <租户编码>",
8191
+ "tenant-locate": "租户定位在 db 命令组:bfi db tenant-locate <租户编码>",
8192
+ "tool-start": "call 透传路由:bfi ymc call action/tool/start --data '{\"type\":1,...}'",
8193
+ "eventHistograms": "call 透传路由:bfi ymc call eventHistograms ...(无同名子命令)",
8194
+ "exceptionDetail": "call 透传路由:bfi ymc call exceptionDetail ...(无同名子命令)",
8195
+ "app-list": "该端点无查询参数且不支持按服务过滤(列表型导航端点);appId 用推导式 <env>-<appCode>",
8196
+ "warningSqlstat": "用子命令:bfi ymc sqlstat",
8197
+ "warningCallstat": "用子命令:bfi ymc callstat"
8198
+ };
8187
8199
  function assertKnownFlags(sub, rest) {
8188
8200
  const allowed = /* @__PURE__ */ new Set([...COMMON_FLAGS, ...ALLOWED_FLAGS[sub] ?? []]);
8189
8201
  for (const a of rest) {
@@ -8244,6 +8256,21 @@ function rowsSummary(label) {
8244
8256
  return `✓ ${label}: ${Array.isArray(rows) ? rows.length : 0} 条`;
8245
8257
  };
8246
8258
  }
8259
+ function aggSummary(label) {
8260
+ return (data) => {
8261
+ const d = data;
8262
+ const rows = d.rows ?? d;
8263
+ if (!Array.isArray(rows) || !rows.length) return `✓ ${label}: 0 组`;
8264
+ const countCol = [
8265
+ "count",
8266
+ "cnt",
8267
+ "COUNT(*)",
8268
+ "c"
8269
+ ].find((k) => rows.every((r) => r[k] !== void 0));
8270
+ const total = countCol ? rows.reduce((acc, r) => acc + (Number(r[countCol]) || 0), 0) : NaN;
8271
+ return Number.isFinite(total) ? `✓ ${label}: ${rows.length} 组 / 总计 ${total} 条` : `✓ ${label}: ${rows.length} 组`;
8272
+ };
8273
+ }
8247
8274
  async function runYmc(args, globalOpts) {
8248
8275
  const sub = args[0];
8249
8276
  const rest = args.slice(1);
@@ -8393,7 +8420,7 @@ async function runYmc(args, globalOpts) {
8393
8420
  ...requireEnv(rest),
8394
8421
  ...timeOf(rest, false),
8395
8422
  line: Number(opt(rest, "--line") || 50)
8396
- }), jsonMode, rowsSummary(`SLS 全文检索 "${kw}"`));
8423
+ }), jsonMode, aggSummary(`SLS 全文检索 "${kw}"`));
8397
8424
  break;
8398
8425
  }
8399
8426
  case "sls-logs": {
@@ -8713,6 +8740,7 @@ async function runYmc(args, globalOpts) {
8713
8740
  emit(await api.call("ymc/warningCallstat", {
8714
8741
  ...requireEnv(rest),
8715
8742
  ...timeOpts(rest),
8743
+ curAppCode: opt(rest, "--app") || "",
8716
8744
  page: Number(opt(rest, "--page") || 1),
8717
8745
  pageSize: Number(opt(rest, "--page-size") || 20)
8718
8746
  }), jsonMode, rowsSummary("慢调用统计"));
@@ -8721,6 +8749,7 @@ async function runYmc(args, globalOpts) {
8721
8749
  emit(await api.call("ymc/warningSqlstat", {
8722
8750
  ...requireEnv(rest),
8723
8751
  ...timeOpts(rest),
8752
+ curAppCode: opt(rest, "--app") || "",
8724
8753
  page: Number(opt(rest, "--page") || 1),
8725
8754
  pageSize: Number(opt(rest, "--page-size") || 20)
8726
8755
  }), jsonMode, rowsSummary("慢 SQL 统计"));
@@ -8836,10 +8865,13 @@ async function runYmc(args, globalOpts) {
8836
8865
  }, timeoutMs), jsonMode);
8837
8866
  break;
8838
8867
  }
8839
- default:
8868
+ default: {
8840
8869
  console.error(`未知子命令:${sub}`);
8870
+ const hint = SUBCOMMAND_HINTS[sub];
8871
+ if (hint) console.error(`提示:${hint}`);
8841
8872
  printHelp$3();
8842
8873
  process.exit(1);
8874
+ }
8843
8875
  }
8844
8876
  }
8845
8877
  const HELP = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.93",
3
+ "version": "0.1.94",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {