@stalfh233/omc-cli 0.6.76 → 0.6.77

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.
@@ -1258,7 +1258,7 @@
1258
1258
  "lane": "e2e-delivery"
1259
1259
  },
1260
1260
  {
1261
- "capability": "data.list filtered business-object listing",
1261
+ "capability": "data.list listing and data.aggregate counting/grouping",
1262
1262
  "status": "executable",
1263
1263
  "scope": "POST /api/api/runtime/query/list with simplified filters translated to queryCondition (or>and>leaf), pagination, field projection, and trimmed response metadata.",
1264
1264
  "version_family": "8.6",
@@ -1275,10 +1275,12 @@
1275
1275
  ],
1276
1276
  "lane": "M2-runtime-data",
1277
1277
  "tools": [
1278
- "data.list"
1278
+ "data.list",
1279
+ "data.aggregate"
1279
1280
  ],
1280
1281
  "scopes": [
1281
- "filtered list field projection"
1282
+ "filtered list field projection",
1283
+ "aggregate count and grouped distribution via query/list totals"
1282
1284
  ]
1283
1285
  },
1284
1286
  {
@@ -190,8 +190,8 @@ const SURFACES = [
190
190
  id: "data",
191
191
  title: "运行数据",
192
192
  lane: LANES.runtimeData,
193
- description: "运行数据条目的列出、加载、保存、更新、删除、提交。",
194
- operations: ["list", "load", "save", "update", "delete", "submit"],
193
+ description: "运行数据条目的列出、加载、保存、更新、删除、提交,以及计数/分组统计。",
194
+ operations: ["list", "aggregate", "load", "save", "update", "delete", "submit"],
195
195
  requires: ["field"],
196
196
  intent: { level: "none", note: "未覆盖;用 omc call data.*。" },
197
197
  },
@@ -7,6 +7,9 @@ export function dataListDescription() {
7
7
  const wire = RUNTIME_DATA_WIRE;
8
8
  return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;未配列的自定义字段投影为 null——这是显示面缺列配置、不是数据缺失(data.load 有值),显式选列在结果中全为 null 而发布字段元数据显示其存在时,readback 追加 projectionHint(先用 listview.configure 配置该模型的默认视图列,或用 data.load 读单条权威值)。`;
9
9
  }
10
+ export function dataAggregateDescription() {
11
+ return `临时计数/分组统计(纯读,metric=count)。count:runtime/query/list size:1 读 totalElements(服务端精确,不受 cap 1000 影响;带 filter 2 wire=1 field.list 注入 propertyType+1 list)。groupBy 单列且值域可枚举(field.list options/字典)→ 值域×count(V+3 wire:1 metadata+1 base+V 桶+1 isnull),桶按 count 降序取 topN(默认 10/上限 20),截断给 truncatedBuckets/bucketsTruncatedCount,null 单列 nullBucket。不可枚举(自由文本/高基数)→ 1 列投影 all:true(cap 1000)本地计数,coverage.mode=local-scan+missingCount+capNotice,**永不外推行数**。filter.draftPolicy:groupBy 默认 includeDrafts:false 注入 sequenceStatus≠DRAFT(excluded)统一双口径;count 省略=平台默认(无条件下含草稿 included、带条件排草稿 excluded);显式 false 可强制排除。边界:临时问句用本工具;持久图表/看板用 report.chartdata,视图汇总列用 sumType,写时计算用 datarule type2。`;
12
+ }
10
13
  export function dataUpdateDescription() {
11
14
  const wire = RUNTIME_DATA_WIRE;
12
15
  return describeTool("M2 runtime data UPDATE (runtime/form/save with data.id, bizObjectId arg).", [
@@ -120,6 +123,7 @@ export const RUNTIME_DATA_LANE_CONTRACT = Object.freeze({
120
123
  ]),
121
124
  tools: Object.freeze({
122
125
  "data.list": Object.freeze({ scope: "filtered list field projection", description: dataListDescription() }),
126
+ "data.aggregate": Object.freeze({ scope: "aggregate count and grouped distribution via query/list totals", description: dataAggregateDescription() }),
123
127
  "data.load": Object.freeze({ scope: "authoritative readback form load", description: "M2 authoritative readback: form/load one business object by id. **返回形状:业务字段值在 `result.data`(非 readback.authoritative);大结果 stdout 只回 detailArtifactId + fetch 提示,用 `omc artifact get <id>` 取回;`fields:[...]` 可投影只取所需键**。" }),
124
128
  "data.save": Object.freeze({
125
129
  scope: "write authoritative readback form save",
@@ -142,6 +146,7 @@ function desc(lead) {
142
146
  export function assertRuntimeDataContract() {
143
147
  assertLaneContract(RUNTIME_DATA_LANE_CONTRACT);
144
148
  assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.list", ["queryCondition", "propertyType", "rawCondition", "projectionHint", "listview.configure", "data.load", "items[].fields"]);
149
+ assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.aggregate", ["totalElements", "groupBy", "local-scan", "cap 1000", "draftPolicy", "report.chartdata"]);
145
150
  assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.save", ["bizObjectId", "sheetCode", "bizsheet/get", "workflowCode", "sequenceStatus", "workItem", "propertyType 9", "50000", "mappings", "rowStatus", "DRAFT", "submit:true", "CHILD_TABLE"]);
146
151
  assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.update", ["runtime/form/save", "bizObjectId", "COMPLETED", "304001", "form/load", "rowStatus", "child-rows-upsert"]);
147
152
  assertDescriptionCarries(RUNTIME_DATA_LANE_CONTRACT, "data.delete", ["absence", "sheetCode"]);
@@ -17,9 +17,9 @@ export const RUNTIME_DATA_COVERAGE = declareLaneCoverage(RUNTIME_DATA_LANE_CONTR
17
17
  ],
18
18
  },
19
19
  {
20
- capability: "data.list filtered business-object listing",
21
- evidence: ["packages/omc-cli/src/tools.ts", "packages/omc-cli/test/data-list.test.ts"],
22
- tools: [claim("data.list", T["data.list"].scope)],
20
+ capability: "data.list listing and data.aggregate counting/grouping",
21
+ evidence: ["packages/omc-cli/src/tools.ts", "packages/omc-cli/test/data-list.test.ts", "packages/omc-cli/test/data-aggregate.test.ts"],
22
+ tools: [claim("data.list", T["data.list"].scope), claim("data.aggregate", T["data.aggregate"].scope)],
23
23
  },
24
24
  ]);
25
25
  //# sourceMappingURL=runtime-data-coverage.js.map
@@ -442,7 +442,7 @@ function serialGenerationFailures(serialNumberCodes, record, sequenceStatus) {
442
442
  return [];
443
443
  return serialNumberCodes.filter((code) => record[code] === null);
444
444
  }
445
- function choiceCodesFromFieldOptions(field, options) {
445
+ export function choiceCodesFromFieldOptions(field, options) {
446
446
  const asCodes = (value) => {
447
447
  if (!Array.isArray(value))
448
448
  return [];
@@ -1061,6 +1061,37 @@ async function diagnoseDbException(session, schemaCode, error) {
1061
1061
  `定位:依次禁用/删除可疑公式字段再写一次(可逆);形状见 omc describe field.create --example formula-aggregation-cross-model。`,
1062
1062
  });
1063
1063
  }
1064
+ /** `data.aggregate` caps: server-total counts are exact; the local-scan fallback shares data.list's row cap. */
1065
+ const AGGREGATE_CAP = 1000;
1066
+ const AGGREGATE_PAGE_SIZE = 200;
1067
+ /**
1068
+ * One property leaf as a level-1 AND group, so it can be appended to ANY base
1069
+ * condition (leaf / filters / filterGroup) without re-shaping the existing
1070
+ * nesting: level 1 is AND across groups, so `[...base, [[leaf]]]` is exactly
1071
+ * `base AND leaf`.
1072
+ */
1073
+ function aggregateLeafGroup(propertyCode, propertyType, queryFilterType, propertyValue) {
1074
+ return [[{ propertyCode, propertyValue, queryFilterType, propertyType }]];
1075
+ }
1076
+ function withAggregateLeaf(condition, leafGroup) {
1077
+ return condition === undefined ? [leafGroup] : [...condition, leafGroup];
1078
+ }
1079
+ /**
1080
+ * Draft口径(继承 data.list r26/r28b 的键名,调用方同一套分支)。
1081
+ *
1082
+ * - `includeDrafts:false`(含 groupBy 的默认)→ 注入 sequenceStatus≠DRAFT(excluded);
1083
+ * - count 省略 → 平台默认:无条件时含草稿(included),带条件时平台自己排草稿(excluded);
1084
+ * - `includeDrafts:true` → 不注入;无条件时含草稿(included),带条件时平台仍排草稿。
1085
+ */
1086
+ function aggregateDraftFilter(excludedByRequest, includeDrafts, hasUserCondition) {
1087
+ if (excludedByRequest)
1088
+ return { draftPolicy: "excluded", hint: "includeDrafts:false(groupBy 默认)——已注入 sequenceStatus≠DRAFT;total/桶只计非草稿" };
1089
+ if (includeDrafts && hasUserCondition)
1090
+ return { draftPolicy: "excluded", hint: "带条件计数时平台排除草稿(r26/r28b);includeDrafts:true 无法强制包含" };
1091
+ if (hasUserCondition)
1092
+ return { draftPolicy: "excluded", hint: "带条件计数时平台排除草稿(r26/r28b);无条件时 total 含草稿" };
1093
+ return { draftPolicy: "included", hint: includeDrafts ? "无条件计数含草稿(平台口径 r28b);要排除用 includeDrafts:false" : "count 省略 includeDrafts=平台默认:无条件 total 含草稿;要排除显式传 false" };
1094
+ }
1064
1095
  /** Runtime business-object data keyed by field code. */
1065
1096
  export function registerRuntimeDataLane(tools) {
1066
1097
  tools.push(defineTool({
@@ -1574,6 +1605,216 @@ export function registerRuntimeDataLane(tools) {
1574
1605
  });
1575
1606
  },
1576
1607
  }));
1608
+ tools.push(defineTool({
1609
+ name: "data.aggregate",
1610
+ search: { intents: ["分组计数", "聚合计数", "计数汇总", "按状态分组", "值域分布", "分组分布", "每类几个", "分桶计数"] },
1611
+ layer: "low",
1612
+ kind: "read",
1613
+ lane: RUNTIME_LANE,
1614
+ scope: RUNTIME_TOOLS["data.aggregate"].scope,
1615
+ description: RUNTIME_TOOLS["data.aggregate"].description,
1616
+ inputSchema: {
1617
+ environment: environmentArg,
1618
+ schemaCode: z.string().min(1),
1619
+ // 三个过滤参数与 data.list 同语义(DSL 翻译与 propertyType 注入复用同一套件)。
1620
+ filter: z.union([z.record(z.string(), z.unknown()), z.array(z.record(z.string(), z.unknown()))]).optional().describe('单子句 {op,field,value?}(或子句数组=AND);op 同 data.list(eq/neq/gt/lt/gte/lte/like/in/notin/isnull/isnotnull 等)'),
1621
+ filters: z.array(z.record(z.string(), z.unknown())).optional().describe("子句数组=AND"),
1622
+ filterGroup: z.record(z.string(), z.unknown()).optional().describe('嵌套组 {op:"and"|"or",clauses:[…]}'),
1623
+ metric: z.enum(["count"]).describe("首片仅 count(服务端 totalElements 精确);sum/avg/min/max 第二批"),
1624
+ groupBy: z.string().min(1).optional().describe("单列分组:值域可枚举走「值域×count」;不可枚举(自由文本/高基数)退化为本地扫描(cap 1000,截断时 complete:false+capNotice)"),
1625
+ topN: z.number().int().min(1).max(20).default(10).describe("分组桶上限,默认 10、上限 20(按 count 降序)"),
1626
+ includeDrafts: z.boolean().optional().describe("groupBy 默认 false(注入 sequenceStatus≠DRAFT 统一双口径);count 省略=平台默认(无条件含草稿、带条件排草稿);显式 false 可强制排除——口径看 filter.draftPolicy"),
1627
+ capability: capabilityArg,
1628
+ },
1629
+ handler: async (ctx, args, self) => {
1630
+ // groupBy 要统一 base 与各桶的口径,省略时默认排除草稿;count 省略时保留
1631
+ // 平台默认(无条件含草稿),只有显式 false 才注入排除条件。
1632
+ const excludedByRequest = args.includeDrafts === false || (args.includeDrafts === undefined && args.groupBy !== undefined);
1633
+ const includeDrafts = args.includeDrafts === true;
1634
+ // 用户条件与草稿注入分开构造:filterGroup 会把 filters 覆盖掉(toQueryCondition
1635
+ // 的既有语义),所以草稿条件统一按「level1 AND 追加一组」合并,任何 DSL 形状都不丢。
1636
+ let userCondition;
1637
+ try {
1638
+ const asFilters = args.filters ?? (Array.isArray(args.filter) ? args.filter : undefined);
1639
+ const asFilter = Array.isArray(args.filter) ? undefined : args.filter;
1640
+ userCondition = toQueryCondition({
1641
+ ...(asFilter !== undefined ? { filter: asFilter } : {}),
1642
+ ...(asFilters !== undefined && asFilters.length > 0 ? { filters: asFilters } : {}),
1643
+ ...(args.filterGroup !== undefined ? { filterGroup: args.filterGroup } : {}),
1644
+ });
1645
+ }
1646
+ catch (error) {
1647
+ if (error instanceof FilterDslError)
1648
+ return {
1649
+ status: "refused",
1650
+ blocker: "invalid-filter-DSL",
1651
+ reason: error.code,
1652
+ message: `${error.message};filter 最小形状 {"op":"eq","field":"<字段code>","value":"<值>"};多条件 filters:[…](AND)或 filterGroup:{op,clauses:[…]}`,
1653
+ minimalValidFilter: { filter: { op: "eq", field: "<fieldCode>", value: "<value>" } },
1654
+ };
1655
+ throw error;
1656
+ }
1657
+ const hasUserCondition = userCondition !== undefined;
1658
+ let condition = excludedByRequest ? withAggregateLeaf(userCondition, aggregateLeafGroup("sequenceStatus", 0, "NotEq", "DRAFT")) : userCondition;
1659
+ return governedRead(ctx, self, args, async (session) => {
1660
+ const draftFilter = aggregateDraftFilter(excludedByRequest, includeDrafts, hasUserCondition);
1661
+ let metaCalls = 0;
1662
+ let published;
1663
+ // field.list 至多一跳:同时服务 filter 的 propertyType 注入与 groupBy 值域解析。
1664
+ const fieldMeta = async () => {
1665
+ if (published !== undefined)
1666
+ return published;
1667
+ metaCalls += 1;
1668
+ try {
1669
+ const rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data);
1670
+ const map = new Map();
1671
+ for (const row of rows) {
1672
+ const code = String(row.code ?? row.propertyCode ?? "");
1673
+ if (!code)
1674
+ continue;
1675
+ map.set(code, {
1676
+ type: Number(row.propertyType ?? row.type),
1677
+ choiceCodes: choiceCodesFromFieldOptions(row, parseOptions(row.options)),
1678
+ });
1679
+ }
1680
+ published = map;
1681
+ }
1682
+ catch {
1683
+ published = null;
1684
+ }
1685
+ return published;
1686
+ };
1687
+ // Only a USER DSL filter needs published metadata; the injected draft
1688
+ // leaf (sequenceStatus) has a platform-fixed propertyType.
1689
+ if (hasUserCondition) {
1690
+ const meta = await fieldMeta();
1691
+ const injected = injectPropertyTypes(condition, (code) => {
1692
+ const type = meta?.get(code)?.type;
1693
+ return type !== undefined && Number.isInteger(type) ? type : undefined;
1694
+ });
1695
+ if (!injected.ok)
1696
+ return {
1697
+ status: "refused",
1698
+ blocker: "unknown-filter-field",
1699
+ schemaCode: args.schemaCode,
1700
+ missing: injected.missing,
1701
+ message: `filter 字段不在已发布元数据里:${injected.missing.join("、")}(聚合复用 data.list 的 propertyType 注入,不做猜测)`,
1702
+ nextCommand: `omc call field.list --env <env> --args '{"schemaCode":"${args.schemaCode}","published":true}'`,
1703
+ };
1704
+ condition = injected.condition;
1705
+ }
1706
+ const queryBody = (size, page) => ({
1707
+ schemaCode: args.schemaCode,
1708
+ queryCode: args.schemaCode,
1709
+ filters: [],
1710
+ mobile: false,
1711
+ page,
1712
+ size,
1713
+ queryVersion: 1,
1714
+ showTotal: true,
1715
+ ...(condition !== undefined ? { queryCondition: condition } : {}),
1716
+ });
1717
+ const countAt = async (extraLeaf) => {
1718
+ const body = queryBody(1, 0);
1719
+ if (extraLeaf !== undefined)
1720
+ body.queryCondition = withAggregateLeaf(condition, extraLeaf);
1721
+ const response = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body });
1722
+ return extractBizObjectPage(response.data).total;
1723
+ };
1724
+ const topN = args.topN ?? 10;
1725
+ // 1) 无 groupBy:service-total 精确计数(1 wire;带用户 filter 时 +1 元数据)。
1726
+ if (args.groupBy === undefined) {
1727
+ const total = await countAt();
1728
+ return {
1729
+ schemaCode: args.schemaCode,
1730
+ metric: "count",
1731
+ total,
1732
+ coverage: { mode: "server-total", rowsScanned: 0, cap: AGGREGATE_CAP, complete: true },
1733
+ filter: draftFilter,
1734
+ wire: { calls: metaCalls + 1, plan: metaCalls > 0 ? "1 metadata + 1 base" : "1 base" },
1735
+ };
1736
+ }
1737
+ // 2/3) groupBy:值域可枚举 → 值域×count;否则 1 列投影本地扫描。
1738
+ const meta = await fieldMeta();
1739
+ const groupField = meta?.get(args.groupBy);
1740
+ const codes = groupField?.choiceCodes ?? [];
1741
+ if (groupField && Number.isInteger(groupField.type) && codes.length > 0) {
1742
+ const baseTotal = await countAt();
1743
+ const buckets = [];
1744
+ for (const code of codes) {
1745
+ const count = await countAt(aggregateLeafGroup(args.groupBy, groupField.type, "Eq", code));
1746
+ buckets.push({ key: code, count });
1747
+ }
1748
+ const nullCount = await countAt(aggregateLeafGroup(args.groupBy, groupField.type, "IsNull", ""));
1749
+ const sums = buckets.reduce((sum, bucket) => sum + bucket.count, 0);
1750
+ const unaccounted = baseTotal - sums - nullCount;
1751
+ buckets.sort((left, right) => right.count - left.count || left.key.localeCompare(right.key));
1752
+ const shown = buckets.slice(0, topN);
1753
+ return {
1754
+ schemaCode: args.schemaCode,
1755
+ metric: "count",
1756
+ groupBy: args.groupBy,
1757
+ total: baseTotal,
1758
+ buckets: shown,
1759
+ nullBucket: { count: nullCount },
1760
+ truncatedBuckets: buckets.length > shown.length,
1761
+ bucketsTruncatedCount: buckets.length - shown.length,
1762
+ ...(unaccounted > 0 ? { unaccountedCount: unaccounted } : {}),
1763
+ coverage: { mode: "server-total", rowsScanned: 0, cap: AGGREGATE_CAP, complete: true },
1764
+ filter: draftFilter,
1765
+ wire: { calls: metaCalls + 1 + codes.length + 1, plan: `1 metadata + 1 base + ${codes.length} buckets + 1 null` },
1766
+ };
1767
+ }
1768
+ // 自由文本/高基数:翻页取前 cap 行,只投影 groupBy 列本地计数;绝不按扫描比例外推。
1769
+ const counts = new Map();
1770
+ let nullCount = 0;
1771
+ let rowsScanned = 0;
1772
+ let total = 0;
1773
+ let pages = 0;
1774
+ for (let page = 0; rowsScanned < AGGREGATE_CAP; page += 1) {
1775
+ const response = await wireCall(session, { path: ENDPOINTS.runtimeQueryList, method: "POST", body: queryBody(AGGREGATE_PAGE_SIZE, page) });
1776
+ pages += 1;
1777
+ const pageData = extractBizObjectPage(response.data);
1778
+ if (pages === 1)
1779
+ total = pageData.total;
1780
+ if (pageData.content.length === 0)
1781
+ break;
1782
+ for (const row of pageData.content) {
1783
+ const data = row.data && typeof row.data === "object" ? row.data : row;
1784
+ const raw = data[args.groupBy];
1785
+ if (raw === null || raw === undefined)
1786
+ nullCount += 1;
1787
+ else {
1788
+ const key = String(raw);
1789
+ counts.set(key, (counts.get(key) ?? 0) + 1);
1790
+ }
1791
+ }
1792
+ rowsScanned += pageData.content.length;
1793
+ if (rowsScanned >= total)
1794
+ break;
1795
+ }
1796
+ const allBuckets = [...counts].map(([key, count]) => ({ key, count })).sort((left, right) => right.count - left.count || left.key.localeCompare(right.key));
1797
+ const shown = allBuckets.slice(0, topN);
1798
+ const complete = rowsScanned >= total;
1799
+ return {
1800
+ schemaCode: args.schemaCode,
1801
+ metric: "count",
1802
+ groupBy: args.groupBy,
1803
+ total,
1804
+ buckets: shown,
1805
+ nullBucket: { count: nullCount },
1806
+ truncatedBuckets: allBuckets.length > shown.length,
1807
+ bucketsTruncatedCount: allBuckets.length - shown.length,
1808
+ coverage: { mode: "local-scan", rowsScanned, cap: AGGREGATE_CAP, complete, missingCount: Math.max(0, total - rowsScanned) },
1809
+ filter: draftFilter,
1810
+ ...(complete ? {} : {
1811
+ capNotice: `值域非可枚举:已扫前 ${rowsScanned}/${total} 行,桶只覆盖已扫部分(complete:false,非全集)。要全集:filters 按日期/业务键 gte/lt 分片重跑,或 page/size 手动翻页。`,
1812
+ }),
1813
+ wire: { calls: metaCalls + pages, plan: `${metaCalls > 0 ? "1 metadata + " : ""}${pages} pages` },
1814
+ };
1815
+ }, { target: `data.aggregate:${JSON.stringify({ schemaCode: args.schemaCode, metric: args.metric, filter: args.filter, filters: args.filters, filterGroup: args.filterGroup, groupBy: args.groupBy, topN: args.topN ?? 10, includeDrafts: args.includeDrafts ?? null })}` });
1816
+ },
1817
+ }));
1577
1818
  tools.push(defineTool({
1578
1819
  name: "data.load",
1579
1820
  search: { intents: ["读一条记录", "按id查记录", "看单条数据", "读业务数据详情"] },
@@ -70,6 +70,11 @@ const READ_SHAPES = {
70
70
  "data.load": {
71
71
  keys: ["bizObjectId", "exists", "data:{...}"],
72
72
  },
73
+ // r80:计数/分组统计的读回面。notes 只显首条——把陷阱并进第一句。
74
+ "data.aggregate": {
75
+ keys: ["schemaCode", "metric", "groupBy?", "total", "buckets:array<{key,count}>", "nullBucket:{count}", "truncatedBuckets", "bucketsTruncatedCount", "unaccountedCount?", "coverage:{mode,rowsScanned,cap,complete,missingCount?}", "filter:{draftPolicy,hint}", "wire:{calls,plan}", "capNotice?", "environmentFingerprint"],
76
+ notes: ["计数用 total(服务端 totalElements,精确);分组是「值域×count」——buckets[].key 是字段存储值/code,null 单列 nullBucket;coverage.complete:false 时只覆盖已扫行,勿外推"],
77
+ },
73
78
  "app.list": {
74
79
  keys: ["applications:array<{code,name,groupId?,modelCount}>", "applicationsCount", "omitted"],
75
80
  notes: ["applicationsCount + omitted 与 discover 同构;omitted:false 表示内联即全集"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.76",
3
+ "version": "0.6.77",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "14.0.3",
59
- "omc-core": "0.6.76",
59
+ "omc-core": "0.6.77",
60
60
  "proper-lockfile": "4.1.2",
61
61
  "write-file-atomic": "6.0.0",
62
62
  "zod": "^3.23.8",
@@ -74,6 +74,6 @@
74
74
  "directory": "packages/omc-cli"
75
75
  },
76
76
  "optionalDependencies": {
77
- "@stalfh233/omc-fake-platform": "0.6.76"
77
+ "@stalfh233/omc-fake-platform": "0.6.77"
78
78
  }
79
79
  }
@@ -307,14 +307,15 @@ omc call service.get --env local --args '{"serviceCode":"omc_demo_restful"}'
307
307
  | `/api/...` + `xclient` | 双层 | 混用 | ❌ `401 权限不够` |
308
308
  | `/externalLink/...` | 单层免鉴权 | 无 | ⚠️ 能通但方向错误,**禁止**用于二开接口 |
309
309
 
310
- - **排障先找同 adapter 的既有成功服务当形状模板**:`service.list` → `service.get`,看它的方法 url 前缀与鉴权方式(如 `save` = `/openapi/employee/save` + `xclient`),照抄形状,别从零试。
311
- - 二开扩展接口走 `/openapi` + `xclient`;不要用免鉴权前缀承载业务接口。
312
310
 
313
311
  BIZ_ACTION:
314
312
 
315
313
  - 先读方法输入/输出参数面。
316
314
  - `codeType: 1` 的 PROPERTY 输入:`bizCode` 是源字段 code,`propertyName` 是显示名,`serviceMethodParameterCode` 必须命中方法参数。
317
315
  - **常量入参用 `codeType: 0`(CONST)**(如固定请求头 `X-LowCode-Corpid`):值可放 `bizCode`,也可放 `value`(工具会自动移入 `bizCode`)。平台 CONST **只读 `bizCode`**——`value`/`expressionValue` 原样存着的话,运行时取到的是字面 `null`。
316
+ - **`codeType` 全枚举**:0=常量/1=字段(都放 `bizCode`)、2·3=对象/对象数组(`externParameterType` 1001/1002 + `subParameters[]`)、4=规则变量、5=主表、6=系统、**7=表达式**。
317
+ - **7 的 `bizCode` 是字符串化 JSON**:`{"formula":"NOW()","editorText":"NOW()","editorMark":"field-x"}`(`{字段code}` 引用;`expressionValue` 不是 wire 键)。
318
+ - **条件函数按环境实测**(本租户 `IF(` 命中 0):要「按字段取不同来源」先试 `formula:IF(...)`,不可用就拆多个 BIZ_ACTION + 各节点 `execCondition`。
318
319
  - 参数面每参数必带 `bizPropertyType`(参数类型),否则业务规则按类型匹配字段会失败、映射不到(缺失即拒绝);`externParameterType`/`description` 工具补齐。**返回值参数默认不必填(`required:false`),入参按需必填**——返回值声明为必填会经规则 designer 的 `required` 镜像强制每条输出映射也必填,是绑定摩擦的常见来源。
319
320
  - `rule.save` 自动补 `serviceName`/`serviceMethodName`/节点 `nodeCategory:"actionNode"`/映射元素 `index`(弹窗异步加载,稍候再判空)。
320
321
  - 配规则后读回 methodMapping,再用 `rule.run` 或流程实际触发一次。
@@ -205,9 +205,9 @@ only the section for the capability you need —
205
205
 
206
206
  ## 运行数据 `data`
207
207
 
208
- - **能做哪些事**:业务记录列出、加载、保存、更新、删除、提交(工作流)。
209
- - **工具**:`data.list`、`data.load`、`data.save`、`data.update`、`data.delete`、`data.submit`
210
- - **聚合/分组/计数(10 秒答案)**:`data.*` **没有 group-by/聚合工具**——小结果集(≤几百条)用 `data.list` 拉 filter 收窄后的全量 + `--jq '.result.items[].fields.<分组列>'` 投影,本地计数即可;跨模型汇总/大结果集/定时聚合才涉及 report 章节或字段计算(datarule type2 / formula 聚合),**不要**为「数一下条数」引入 report(r60c-F11 真机 2026-11-13:统计问句的正路一句话就该给全)。
208
+ - **能做哪些事**:业务记录列出、加载、保存、更新、删除、提交(工作流)、临时计数/分组统计。
209
+ - **工具**:`data.list`、`data.aggregate`、`data.load`、`data.save`、`data.update`、`data.delete`、`data.submit`
210
+ - **聚合/分组/计数(10 秒答案)**:计数/分组计数直接用 `data.aggregate`(`metric:"count"`)——无 groupBy 读服务端 `total`(精确、1 wire);`groupBy` 值域可枚举时按「值域×count」给各桶(V+3 wire)+ null 桶;自由文本/高基数退化为本地扫描(cap 1000,`coverage.complete:false` + `capNotice`,**不外推行数**)。手工原语仍是 `data.list size:1 + filter` 只读 `total`;跨模型汇总/定时聚合才涉及 report 章节或字段计算(datarule type2 / formula 聚合),**不要**为「数一下条数」引入 report(r60c-F11 真机 2026-11-13:统计问句的正路一句话就该给全)。
211
211
  - **recipe**:
212
212
  - `omc describe data.save --example workflow-backed-data-save`
213
213
  - `omc describe data.submit --example workflow-backed-data-submit`(有流程)
@@ -156,6 +156,7 @@ omc call field.publish --env local --args '{"schemaCode":"expense"}'
156
156
 
157
157
  - 规则节点缺 `nodeName` 时 CLI 按平台 `RuleNodeType` 补默认名并给 warning;业务节点优先显式命名。
158
158
  - BIZ_ACTION 先 `service.get` 读取现存方法参数面,再写 methodMapping。PROPERTY 输入使用 `codeType: 1`、`bizCode` 为业务字段 code、`propertyName` 为显示名、`serviceMethodParameterCode` 命中方法参数。
159
+ - methodMapping 入参 `codeType` 全枚举(0 常量/1 字段/2·3 对象/4 规则变量/5 主表/6 系统/**7 表达式**)与 7 的 `bizCode` JSON 三键(formula/editorText/editorMark)见 `omc help omc-business-configuration` 的 BIZ_ACTION 段;`expressionValue` 不是 wire 键。
159
160
  - **`codeType:1` 映射的 `bizCode` 必须是该模型上**已创建且已发布**的字段 code**:指向不存在/未发布的字段时,平台 publish 只回一个**无明细的 `550018 保存规则失败,规则存在异常`**(真因只经设计器「检测」/`POST /api/app/businessrule/node_run_map → notExistPropertyObjectList` 可见)。`rule.save` 现已本地前置校验并拒绝(`rule-graph-bizaction-mapping-field-missing`);改字段族类型也要同步映射。
160
161
  - **把 BIZ_ACTION 挂到预置数据事件规则(`Create`/`Update`)上时**:映射的 `bizCode` 数据项必须真实存在于该模型,否则发布被拒 `550010 业务规则使用的数据项不存在`(典型:REST 短文本入参要映射一个关联字段——先在模型加一个短文本「快照」字段承接,再映射它)。若预置规则仍不接受,改挂**自定义按钮触发规则**(`customTrigger:true`)或 `Update` 规则,更稳;不要因此判定“平台不支持 BIZ_ACTION”。
161
162
  - **BIZ_ACTION 的 `outputMappings` 按“响应 JSON 根级路径”取值**(源码 `MapOps.toMapByBizServiceJson`/`convertJsonObject`:keyMap 以 `serviceMethodParameterCode` 为键,与响应体**根级**各键匹配)。所以 `serviceMethodParameterCode` 必须等于 REST 响应**根级**的键名: