@stalfh233/omc-cli 0.6.85 → 0.6.86

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/README.md CHANGED
@@ -148,7 +148,7 @@ omc call discover_environment --env <env> --args '{}' # 环境就绪(真实
148
148
 
149
149
  - **覆盖**:`executable` 全量可用;`partial` 有取证边界(见 `omc capability <id>` 的 notes)。
150
150
  - **intent**:`partial` 表示该能力可声明式(`omc intent`)覆盖一部分——通常 create/update;
151
- `none` 表示只走 `omc call`。仍走 `omc call` 逃生舱的删除/增量面:服务/方法删除、给既有服务加方法、
151
+ `none` 表示只走 `omc call`。仍走 `omc call` 逃生舱的删除/增量面:服务/方法删除、
152
152
  分类/连接池/IE,以及 listview 业务筛选/排序/按钮等前端配置。
153
153
 
154
154
  ## 近期能力(0.4.84 → 0.6.29)
@@ -262,10 +262,11 @@ omc intent readback intent.yaml --env <env> # 解码回 intent 形状做等价
262
262
 
263
263
  - 顶层 `models[]` / `services[]`;各能力声明式覆盖程度见「能力总览」的 intent 列(`partial` = 覆盖 create/update 等一部分)。
264
264
  - 模型内字段级数据规则用 `models[].datarules[]` 声明(create/update:type、options、`checkType`、`childRule`;delete:`absent:true`),编译时自动依赖已发布字段。
265
+ - 业务集成:`services[]` 的 `method`(单方法,name==code,随 `service.register`)与 `methods[]`(多方法,name 可不同于 code;缺失 plan `method.create`、漂移 plan `method.update`,既有服务加方法也走这里)互斥。
265
266
  - 显式缺席(删除):`models[].absent:true` 删整模型、`fields[].absent:true` 删单字段、`listview.absent:true` 删列表视图、`datarules[].absent:true` 删数据规则;plan 的 `riskClass` 升为 `destructive`。
266
267
  - **plan 不可变**:apply 前 plan 被改一字节即拒(`intent-plan-tampered`),plan 后环境漂移即拒(`intent-baseline-drifted`,重跑 `intent plan`)。
267
268
  - 生产环境 apply 加 `--confirm-production`;`--dry-run` 预览,`--no-verify` 跳过最终读回等价确认。
268
- - 未声明式覆盖的操作(服务/方法删除与加方法、分类/连接池/IE 等)仍走 `omc call` 逃生舱。
269
+ - 未声明式覆盖的操作(服务/方法删除、分类/连接池/IE 等)仍走 `omc call` 逃生舱。
269
270
 
270
271
  ## 其它命令
271
272
 
@@ -172,9 +172,9 @@ const SURFACES = [
172
172
  title: "业务集成",
173
173
  lane: LANES.b2,
174
174
  description: "业务服务与方法注册(RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA/SOAP)、服务清单(按分类/关键词,凭据不回显)、导入导出、设计器测试、调用日志(h_log_biz_service 读面:params/result/状态/耗时)。",
175
- operations: ["list", "register", "update", "delete", "export", "import", "check", "test", "log"],
175
+ operations: ["list", "register", "update", "method.create", "method.update", "delete", "export", "import", "check", "test", "log"],
176
176
  requires: [],
177
- intent: { level: "partial", note: "声明式支持新建 service.register(可带一个 method)与既有 service/method 的 update(结构化 config、AES 加密、patch 语义);删除、给既有服务加方法、分类/连接池/IE 仍走 escape hatch。" },
177
+ intent: { level: "partial", note: "声明式支持新建 service.register(可带一个 method 或 methods[] 多方法,后者 name 可不同于 code)与既有 service/method 的 update,含给既有服务加方法(method.create);删除、分类/连接池/IE 仍走 escape hatch。" },
178
178
  notes: "方法 configJson 走 AES-128-ECB;RESTFUL/DATA_SQL 绑定前须带适配器必需配置(否则是注册壳)。",
179
179
  },
180
180
  {
@@ -6,20 +6,42 @@ import { sameValue } from "../compare.js";
6
6
  import { isScalarString, pushError } from "../validation.js";
7
7
  import { toPlain } from "../yaml.js";
8
8
  import { errorDetail } from "../../tool-types.js";
9
- const SERVICE_KEYS = new Set(["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig", "method"]);
9
+ const SERVICE_KEYS = new Set(["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig", "method", "methods"]);
10
10
  const METHOD_KEYS = new Set(["code", "name", "methodConfig", "inputParameters", "outputParameters"]);
11
11
  function configError(error) {
12
12
  return errorDetail(error);
13
13
  }
14
+ /** Every method declaration a service carries (legacy `method` or `methods[]`). */
15
+ function declaredMethods(service) {
16
+ if (service.methods !== undefined)
17
+ return service.methods;
18
+ return service.method ? [service.method] : [];
19
+ }
14
20
  function compileService(service) {
15
21
  assertBizServiceAdapterWhitelisted(service.adapterCode);
16
22
  const serviceConfig = compileServiceConfig(service.adapterCode, service.serviceConfig);
17
- if (!service.method)
18
- return { serviceConfig };
19
- const methodConfig = service.method.methodConfig === undefined ? undefined : compileMethodConfigPlain(service.adapterCode, service.method.methodConfig);
20
- const input = service.method.inputParameters === undefined ? undefined : compileParameterFace(service.adapterCode, service.method.inputParameters, "methodInputParameters");
21
- const output = service.method.outputParameters === undefined ? undefined : compileParameterFace(service.adapterCode, service.method.outputParameters, "methodOutputParameters");
22
- return { serviceConfig, ...(methodConfig !== undefined ? { methodConfig } : {}), ...(input !== undefined ? { input } : {}), ...(output !== undefined ? { output } : {}) };
23
+ // Offline adapter/config/parameter-face validation for EVERY declared method
24
+ // (the write tools re-run the same compile, this catches it before any wire).
25
+ for (const method of declaredMethods(service)) {
26
+ if (method.methodConfig !== undefined)
27
+ compileMethodConfigPlain(service.adapterCode, method.methodConfig);
28
+ if (method.inputParameters !== undefined)
29
+ compileParameterFace(service.adapterCode, method.inputParameters, "methodInputParameters");
30
+ if (method.outputParameters !== undefined)
31
+ compileParameterFace(service.adapterCode, method.outputParameters, "methodOutputParameters");
32
+ }
33
+ return { serviceConfig };
34
+ }
35
+ /** Exact `method.create`/`method.update` args for one declared method (plaintext config; the tool AES-encrypts). */
36
+ function methodArgs(service, method) {
37
+ return {
38
+ serviceCode: service.code,
39
+ methodCode: method.code,
40
+ name: method.name,
41
+ ...(method.methodConfig !== undefined ? { methodConfig: method.methodConfig } : {}),
42
+ ...(method.inputParameters !== undefined ? { methodInputParameters: method.inputParameters } : {}),
43
+ ...(method.outputParameters !== undefined ? { methodOutputParameters: method.outputParameters } : {}),
44
+ };
23
45
  }
24
46
  function serviceArgs(service) {
25
47
  compileService(service);
@@ -55,32 +77,59 @@ function expectedParameterFace(adapterCode, parameters, label) {
55
77
  return undefined;
56
78
  return normalizeParameterFaceReadback(adapterCode, JSON.parse(compileParameterFace(adapterCode, parameters, label)));
57
79
  }
58
- function serviceFromRow(service, method, adapterCode) {
59
- const decode = (value) => {
60
- if (typeof value !== "string")
61
- return value;
62
- try {
63
- return JSON.parse(value);
64
- }
65
- catch {
66
- return value;
67
- }
68
- };
69
- const methodFace = method ? {
80
+ /**
81
+ * Parameter-face equivalence. An undeclared face, a platform `null`, and a
82
+ * stored EMPTY face (`[]`) all mean "no parameters": the real platform persists
83
+ * `inputParametersJson`/`outputParametersJson` as `[]` even when the intent
84
+ * declares none, while the fake answers `null` — comparing them raw produced
85
+ * phantom `method-mismatch` on live apply (W12A acceptance). A NON-EMPTY stored
86
+ * face still fails against an undeclared one.
87
+ */
88
+ function sameParameterFace(live, expected) {
89
+ const empty = (value) => (value === undefined || value === null || (Array.isArray(value) && value.length === 0) ? [] : value);
90
+ return sameValue(empty(live), empty(expected));
91
+ }
92
+ function decodeColumn(value) {
93
+ if (typeof value !== "string")
94
+ return value;
95
+ try {
96
+ return JSON.parse(value);
97
+ }
98
+ catch {
99
+ return value;
100
+ }
101
+ }
102
+ function methodFaceFromRow(method, adapterCode) {
103
+ return {
70
104
  code: String(method.code ?? ""),
71
105
  present: true,
72
106
  name: typeof method.name === "string" ? method.name : null,
73
- methodConfig: normalizeMethodConfigReadback(adapterCode, decode(method.configJson)),
74
- inputParameters: normalizeParameterFaceReadback(adapterCode, decode(method.inputParametersJson)),
75
- outputParameters: normalizeParameterFaceReadback(adapterCode, decode(method.outputParametersJson)),
76
- } : undefined;
107
+ methodConfig: normalizeMethodConfigReadback(adapterCode, decodeColumn(method.configJson)),
108
+ inputParameters: normalizeParameterFaceReadback(adapterCode, decodeColumn(method.inputParametersJson)),
109
+ outputParameters: normalizeParameterFaceReadback(adapterCode, decodeColumn(method.outputParametersJson)),
110
+ };
111
+ }
112
+ /**
113
+ * Project the service row + declared methods. The legacy `method` slice keeps
114
+ * its historical shape (the key is OMITTED when the method is absent) so old
115
+ * plans/readbacks stay byte-identical; `methods[]` rows are always present so
116
+ * the planner/readback can name every declared-but-missing code.
117
+ */
118
+ function serviceFromRow(service, adapterCode, rowsByCode, declared) {
119
+ const legacyRow = declared.method ? rowsByCode.get(declared.method.code) : undefined;
77
120
  return {
78
121
  code: String(service?.code ?? ""),
79
122
  present: service !== null,
80
123
  name: typeof service?.name === "string" ? service.name : null,
81
124
  adapterCode: typeof service?.adapterCode === "string" ? service.adapterCode : null,
82
- serviceConfig: decode(service?.configJson),
83
- ...(methodFace ? { method: methodFace } : {}),
125
+ serviceConfig: decodeColumn(service?.configJson),
126
+ ...(legacyRow ? { method: methodFaceFromRow(legacyRow, adapterCode) } : {}),
127
+ ...(declared.methods !== undefined ? {
128
+ methods: declared.methods.map((method) => {
129
+ const row = rowsByCode.get(method.code);
130
+ return row ? methodFaceFromRow(row, adapterCode) : { code: method.code, present: false, name: null };
131
+ }),
132
+ } : {}),
84
133
  };
85
134
  }
86
135
  function validateServiceNode(serviceNode, index, draft, validation) {
@@ -95,6 +144,7 @@ function validateServiceNode(serviceNode, index, draft, validation) {
95
144
  const categoryNode = value("serviceCategoryId");
96
145
  const configNode = value("serviceConfig");
97
146
  const methodNode = value("method");
147
+ const methodsNode = value("methods");
98
148
  if (!isScalarString(codeNode) || codeNode.value.trim().length === 0)
99
149
  pushError(validation, "intent-service-code-invalid", "service.code 必须是非空字符串", `${base}.code`, "value");
100
150
  if (!isScalarString(nameNode) || nameNode.value.trim().length === 0)
@@ -107,57 +157,84 @@ function validateServiceNode(serviceNode, index, draft, validation) {
107
157
  pushError(validation, "intent-service-config-invalid", "service.serviceConfig 必须是映射", `${base}.serviceConfig`, "value");
108
158
  if (methodNode !== undefined && methodNode.kind !== "map")
109
159
  pushError(validation, "intent-service-method-invalid", "service.method 必须是映射", `${base}.method`, "value");
160
+ if (methodsNode !== undefined && methodsNode.kind !== "seq")
161
+ pushError(validation, "intent-service-methods-invalid", "service.methods 必须是列表", `${base}.methods`, "value");
162
+ if (methodNode !== undefined && methodsNode !== undefined)
163
+ pushError(validation, "intent-service-method-both", "service.method 与 service.methods 互斥:单方法(methodName==code)用 method,多方法或给既有服务加方法用 methods", `${base}.methods`, "value");
110
164
  if (!isScalarString(codeNode) || !isScalarString(nameNode) || !isScalarString(adapterNode) || !isScalarString(categoryNode) || configNode?.kind !== "map")
111
165
  return;
112
166
  const serviceConfig = toPlain(configNode);
167
+ /** Parse one method map; `legacy` enforces the service.register name==code constraint. */
168
+ const parseMethod = (map, path, legacy) => {
169
+ for (const entry of map.entries)
170
+ if (!METHOD_KEYS.has(entry.key))
171
+ pushError(validation, "intent-key-unknown", `${path} 不支持键 "${entry.key}"`, `${path}.${entry.key}`);
172
+ const methodValue = (key) => map.entries.find((entry) => entry.key === key)?.value;
173
+ const methodCode = methodValue("code");
174
+ const methodName = methodValue("name");
175
+ const methodConfig = methodValue("methodConfig");
176
+ const input = methodValue("inputParameters");
177
+ const output = methodValue("outputParameters");
178
+ if (!isScalarString(methodCode) || methodCode.value.trim().length === 0)
179
+ pushError(validation, "intent-method-code-invalid", `${path}.code 必须是非空字符串`, `${path}.code`, "value");
180
+ if (!isScalarString(methodName) || methodName.value.trim().length === 0)
181
+ pushError(validation, "intent-method-name-invalid", `${path}.name 必须是非空字符串`, `${path}.name`, "value");
182
+ if (methodConfig !== undefined && methodConfig.kind !== "map")
183
+ pushError(validation, "intent-method-config-invalid", `${path}.methodConfig 必须是映射`, `${path}.methodConfig`, "value");
184
+ if (input !== undefined && input.kind !== "seq")
185
+ pushError(validation, "intent-method-input-invalid", `${path}.inputParameters 必须是列表`, `${path}.inputParameters`, "value");
186
+ if (output !== undefined && output.kind !== "seq")
187
+ pushError(validation, "intent-method-output-invalid", `${path}.outputParameters 必须是列表`, `${path}.outputParameters`, "value");
188
+ if (!isScalarString(methodCode) || !isScalarString(methodName))
189
+ return undefined;
190
+ if (legacy && methodCode.value.trim() !== methodName.value.trim())
191
+ pushError(validation, "intent-method-name-code-mismatch", "当前 service.register 面 methodName 同时作为方法 code/name;method.name 必须等于 method.code(多方法且 name≠code 用 methods[])", `${path}.name`, "value");
192
+ return {
193
+ code: methodCode.value.trim(),
194
+ name: methodName.value.trim(),
195
+ ...(methodConfig?.kind === "map" ? { methodConfig: toPlain(methodConfig) } : {}),
196
+ ...(input?.kind === "seq" ? { inputParameters: input.items.map((item) => toPlain(item)) } : {}),
197
+ ...(output?.kind === "seq" ? { outputParameters: output.items.map((item) => toPlain(item)) } : {}),
198
+ };
199
+ };
113
200
  let method;
201
+ let methods;
114
202
  try {
115
- const methodMap = methodNode?.kind === "map" ? methodNode : undefined;
116
- if (methodMap) {
117
- for (const entry of methodMap.entries)
118
- if (!METHOD_KEYS.has(entry.key))
119
- pushError(validation, "intent-key-unknown", `service.method 不支持键 "${entry.key}"`, `${base}.method.${entry.key}`);
120
- const methodValue = (key) => methodMap.entries.find((entry) => entry.key === key)?.value;
121
- const methodCode = methodValue("code");
122
- const methodName = methodValue("name");
123
- const methodConfig = methodValue("methodConfig");
124
- const input = methodValue("inputParameters");
125
- const output = methodValue("outputParameters");
126
- if (!isScalarString(methodCode) || methodCode.value.trim().length === 0)
127
- pushError(validation, "intent-method-code-invalid", "service.method.code 必须是非空字符串", `${base}.method.code`, "value");
128
- if (!isScalarString(methodName) || methodName.value.trim().length === 0)
129
- pushError(validation, "intent-method-name-invalid", "service.method.name 必须是非空字符串", `${base}.method.name`, "value");
130
- if (methodConfig !== undefined && methodConfig.kind !== "map")
131
- pushError(validation, "intent-method-config-invalid", "service.method.methodConfig 必须是映射", `${base}.method.methodConfig`, "value");
132
- if (input !== undefined && input.kind !== "seq")
133
- pushError(validation, "intent-method-input-invalid", "service.method.inputParameters 必须是列表", `${base}.method.inputParameters`, "value");
134
- if (output !== undefined && output.kind !== "seq")
135
- pushError(validation, "intent-method-output-invalid", "service.method.outputParameters 必须是列表", `${base}.method.outputParameters`, "value");
136
- if (isScalarString(methodCode) && isScalarString(methodName)) {
137
- if (methodCode.value.trim() !== methodName.value.trim())
138
- pushError(validation, "intent-method-name-code-mismatch", "当前 service.register 面 methodName 同时作为方法 code/name;method.name 必须等于 method.code", `${base}.method.name`, "value");
139
- method = {
140
- code: methodCode.value.trim(),
141
- name: methodName.value.trim(),
142
- ...(methodConfig?.kind === "map" ? { methodConfig: toPlain(methodConfig) } : {}),
143
- ...(input?.kind === "seq" ? { inputParameters: input.items.map((item) => toPlain(item)) } : {}),
144
- ...(output?.kind === "seq" ? { outputParameters: output.items.map((item) => toPlain(item)) } : {}),
145
- };
146
- }
203
+ if (methodNode?.kind === "map")
204
+ method = parseMethod(methodNode, `${base}.method`, true);
205
+ if (methodsNode?.kind === "seq") {
206
+ const seenCodes = new Set();
207
+ const parsed = [];
208
+ methodsNode.items.forEach((item, methodIndex) => {
209
+ const path = `${base}.methods[${methodIndex}]`;
210
+ if (item.kind !== "map") {
211
+ pushError(validation, "intent-service-method-invalid", "service.methods 每项必须是映射", path, "value");
212
+ return;
213
+ }
214
+ const parsedMethod = parseMethod(item, path, false);
215
+ if (!parsedMethod)
216
+ return;
217
+ if (seenCodes.has(parsedMethod.code))
218
+ pushError(validation, "intent-method-code-duplicate", `service.methods 内方法 code 重复:${parsedMethod.code}`, `${path}.code`, "value");
219
+ seenCodes.add(parsedMethod.code);
220
+ parsed.push(parsedMethod);
221
+ });
222
+ if (parsed.length > 0)
223
+ methods = parsed;
147
224
  }
148
- compileService({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}) });
225
+ compileService({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}), ...(methods ? { methods } : {}) });
149
226
  }
150
227
  catch (error) {
151
228
  pushError(validation, "intent-service-config-unsupported", configError(error), base, "value");
152
229
  return;
153
230
  }
154
- draft.services.push({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}) });
231
+ draft.services.push({ code: codeNode.value.trim(), name: nameNode.value.trim(), adapterCode: adapterNode.value.trim(), serviceCategoryId: categoryNode.value.trim(), serviceConfig, ...(method ? { method } : {}), ...(methods ? { methods } : {}) });
155
232
  }
156
233
  export const bizserviceCapability = {
157
234
  id: "bizservice",
158
235
  title: "业务集成",
159
236
  requires: [],
160
- operations: ["register"],
237
+ operations: ["register", "method.create", "method.update"],
161
238
  validateRoot(tree, draft, validation) {
162
239
  const servicesNode = tree.entries.find((entry) => entry.key === "services")?.value;
163
240
  if (servicesNode === undefined || (servicesNode.kind === "scalar" && servicesNode.value === null))
@@ -197,12 +274,17 @@ export const bizserviceCapability = {
197
274
  result.push({ code: service.code, present: false, name: null, adapterCode: null });
198
275
  continue;
199
276
  }
200
- let method;
201
- if (service.method) {
277
+ // One method-list read covers every declared method (legacy `method` or
278
+ // `methods[]`); `filterFlag:false` keeps platform-injected parameters raw.
279
+ const wanted = declaredMethods(service);
280
+ const rowsByCode = new Map();
281
+ if (wanted.length > 0) {
202
282
  const rows = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: service.code, filterFlag: "false" } })).data);
203
- method = rows.find((candidate) => candidate.code === service.method.code);
283
+ for (const candidate of rows)
284
+ if (typeof candidate.code === "string")
285
+ rowsByCode.set(candidate.code, candidate);
204
286
  }
205
- result.push(serviceFromRow(row, method, String(row.adapterCode ?? service.adapterCode)));
287
+ result.push(serviceFromRow(row, String(row.adapterCode ?? service.adapterCode), rowsByCode, service));
206
288
  }
207
289
  return result;
208
290
  },
@@ -214,7 +296,12 @@ export const bizserviceCapability = {
214
296
  const args = serviceArgs(service);
215
297
  const resource = `service:${service.code}`;
216
298
  if (!live?.present) {
299
+ // A brand-new service: `method` rides the legacy service.register payload
300
+ // (methodName==code), while `methods[]` registers the service alone and
301
+ // adds each method through method.create after it exists.
217
302
  emit.change("service.register", args, resource, "service-absent");
303
+ for (const method of service.methods ?? [])
304
+ emit.change("method.create", methodArgs(service, method), `method:${service.code}.${method.code}`, "method-absent");
218
305
  continue;
219
306
  }
220
307
  // An existing service is patched, not recreated. adapterCode is fixed at
@@ -226,25 +313,23 @@ export const bizserviceCapability = {
226
313
  emit.change("service.update", { serviceCode: service.code, name: service.name, serviceConfig: service.serviceConfig }, resource, "service-drift");
227
314
  else
228
315
  emit.skip(resource, "service-present");
229
- if (!service.method)
230
- continue;
231
- const methodResource = `method:${service.code}.${service.method.code}`;
232
- if (!live.method?.present)
233
- // The low-level face has method.update/delete but no method.create, and
234
- // method.update refuses an absent method — adding a method to an
235
- // existing service has no declarative tool. Refuse with the path.
236
- refuse("intent-method-create-unsupported", `业务服务 ${service.code} 已存在但没有方法 ${service.method.code};当前面没有声明式“加方法”能力(method.update 要求方法已存在)。删除服务后重建,或走 omc call`, { resource: methodResource });
237
- if (live.method.name !== service.method.name || !sameValue(live.method.methodConfig, expectedMethodConfig(service.adapterCode, service.method.methodConfig)) || !sameValue(live.method.inputParameters, expectedParameterFace(service.adapterCode, service.method.inputParameters, "methodInputParameters")) || !sameValue(live.method.outputParameters, expectedParameterFace(service.adapterCode, service.method.outputParameters, "methodOutputParameters")))
238
- emit.change("method.update", {
239
- serviceCode: service.code,
240
- methodCode: service.method.code,
241
- name: service.method.name,
242
- ...(service.method.methodConfig !== undefined ? { methodConfig: service.method.methodConfig } : {}),
243
- ...(service.method.inputParameters !== undefined ? { methodInputParameters: service.method.inputParameters } : {}),
244
- ...(service.method.outputParameters !== undefined ? { methodOutputParameters: service.method.outputParameters } : {}),
245
- }, methodResource, "method-drift");
246
- else
247
- emit.skip(methodResource, "method-present");
316
+ // Every declared method is ensured present: absent -> method.create, drift
317
+ // -> method.update, converged -> skip. This is what lets an existing
318
+ // service receive new methods declaratively.
319
+ for (const method of declaredMethods(service)) {
320
+ const methodResource = `method:${service.code}.${method.code}`;
321
+ const liveMethod = service.methods !== undefined
322
+ ? live.methods?.find((entry) => entry.code === method.code)
323
+ : live.method;
324
+ if (!liveMethod?.present) {
325
+ emit.change("method.create", methodArgs(service, method), methodResource, "method-absent");
326
+ continue;
327
+ }
328
+ if (liveMethod.name !== method.name || !sameValue(liveMethod.methodConfig, expectedMethodConfig(service.adapterCode, method.methodConfig)) || !sameParameterFace(liveMethod.inputParameters, expectedParameterFace(service.adapterCode, method.inputParameters, "methodInputParameters")) || !sameParameterFace(liveMethod.outputParameters, expectedParameterFace(service.adapterCode, method.outputParameters, "methodOutputParameters")))
329
+ emit.change("method.update", methodArgs(service, method), methodResource, "method-drift");
330
+ else
331
+ emit.skip(methodResource, "method-present");
332
+ }
248
333
  }
249
334
  },
250
335
  decodeRoot(baseline, live) {
@@ -261,12 +346,16 @@ export const bizserviceCapability = {
261
346
  }
262
347
  if (current.name !== service.name || current.adapterCode !== service.adapterCode || !sameValue(current.serviceConfig, service.serviceConfig))
263
348
  emit.difference("service-mismatch", resource, `业务服务 ${service.code} 的名称/适配器/configJson 不等价`);
264
- if (service.method) {
265
- const method = current.method;
266
- if (!method?.present)
267
- emit.difference("method-missing", `method:${service.code}.${service.method.code}`, `业务方法 ${service.code}/${service.method.code} 不存在`);
268
- else if (method.name !== service.method.name || !sameValue(method.methodConfig, expectedMethodConfig(service.adapterCode, service.method.methodConfig)) || !sameValue(method.inputParameters, expectedParameterFace(service.adapterCode, service.method.inputParameters, "methodInputParameters")) || !sameValue(method.outputParameters, expectedParameterFace(service.adapterCode, service.method.outputParameters, "methodOutputParameters")))
269
- emit.difference("method-mismatch", `method:${service.code}.${service.method.code}`, `业务方法 ${service.code}/${service.method.code} 不等价`);
349
+ for (const declared of declaredMethods(service)) {
350
+ const method = service.methods !== undefined
351
+ ? current.methods?.find((entry) => entry.code === declared.code)
352
+ : current.method;
353
+ if (!method?.present) {
354
+ emit.difference("method-missing", `method:${service.code}.${declared.code}`, `业务方法 ${service.code}/${declared.code} 不存在`);
355
+ continue;
356
+ }
357
+ if (method.name !== declared.name || !sameValue(method.methodConfig, expectedMethodConfig(service.adapterCode, declared.methodConfig)) || !sameParameterFace(method.inputParameters, expectedParameterFace(service.adapterCode, declared.inputParameters, "methodInputParameters")) || !sameParameterFace(method.outputParameters, expectedParameterFace(service.adapterCode, declared.outputParameters, "methodOutputParameters")))
358
+ emit.difference("method-mismatch", `method:${service.code}.${declared.code}`, `业务方法 ${service.code}/${declared.code} 不等价`);
270
359
  }
271
360
  }
272
361
  },
@@ -43,7 +43,7 @@ export function intentCapabilityBlock() {
43
43
  declarativeCapabilities: { model: "partial", field: "partial", businessrule: "partial", datarule: "partial", workflow: "partial", onlinejs: "partial", bizservice: "partial", report: "partial" },
44
44
  absence: "models[].absent:true deletes a whole model; fields[]/listview/datarules[] take absent:true too. Only declared-absent resources are deleted; riskClass becomes destructive and plan.cleanup lists them.",
45
45
  workflowBindings: "models[].workflow.bindRules: [{handler: start|cancel|activate|end, ruleCodes:[...]}] ensures the rules are bound (workflow.bindRule MERGES; undeclared bindings are ignored).",
46
- servicesNote: "top-level services[] registers a new service (optional one method) or patches an existing one; adding a method to an existing service has no declarative tool yet.",
46
+ servicesNote: "top-level services[] registers or patches a service. method (single, name==code, rides service.register) and methods[] (multiple, name may differ from code; missing methods planned as method.create, drift as method.update) are mutually exclusive.",
47
47
  reportsNote: "top-level reports[] creates/configures a report page + BI dashboard (global/attributes/charts); charts diff by uuid, removeUnlistedCharts:true deletes undeclared charts. Only declared reports are touched.",
48
48
  applyVerification: {
49
49
  default: "on",
@@ -53,6 +53,7 @@ export function compileIntent(intent, baseline) {
53
53
  service: service.code,
54
54
  adapterCode: service.adapterCode,
55
55
  ...(service.method ? { methodCode: service.method.code } : {}),
56
+ ...(service.methods ? { methodCodes: service.methods.map((method) => method.code) } : {}),
56
57
  }));
57
58
  const expectedReports = (intent.reports ?? []).map((report) => ({
58
59
  report: report.code,
@@ -164,7 +164,7 @@ export function intentSchemaBlock() {
164
164
  conditionOperators: INTENT_CONDITION_OPERATORS,
165
165
  workflow: { required: ["code", "name", "publish"], optional: ["template", "bindRules"], note: "bindRules [{handler: start|cancel|activate|end, ruleCodes:[...]}];流程事件只绑自定义规则" },
166
166
  onlinejs: { required: ["source", "publish"], optional: ["sheetCode", "replace"], note: "replace:true 覆盖;merge 时 source 只给生命周期片段,不能是完整 (function(form){...})" },
167
- services: { required: ["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig"], optional: ["method"], note: "自定义/INTERNAL 适配器走二开扩展包导入,不在声明式写面" },
167
+ services: { required: ["code", "name", "adapterCode", "serviceCategoryId", "serviceConfig"], optional: ["method", "methods"], note: "method 与 methods 互斥:method 是单方法(name==code,随 service.register);methods[] 是多方法/给既有服务加方法(name 可不同于 code,缺失 plan method.create、漂移 plan method.update)。自定义/INTERNAL 适配器走二开扩展包导入,不在声明式写面" },
168
168
  examples: RUNNABLE_EXAMPLES.map((example) => ({ id: example.id, title: example.title })),
169
169
  exampleHint: "取可运行 YAML:omc describe intent --example <id>",
170
170
  versionNotice: "intent 只覆盖声明式子集(capabilities 的 intent: partial);未覆盖面用 omc call 补齐。",
@@ -8,7 +8,7 @@ export function dataListDescription() {
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
10
  export function dataAggregateDescription() {
11
- return `临时计数与数值聚合(纯读,metric=count|sum|avg|min|max)。count:runtime/query/list size:1 读 totalElements(服务端精确,不受 cap 1000 影响;带 filter 2 wire=1 field.list 注入 propertyType+1 list)。sum/avg/min/max:field 必填且须已发布 propertyType=2(NUMERICAL),本地折叠——列投影+size:200 翻页至 cap 1000,null 行不进聚合、avg=sum/非 null 行数,nonNullCount=0 时 value:null;rowsScanned>=total 才 complete:true,否则 complete:false+missingCount+capNotice,**绝不外推**。groupBy 单列:count 时值域可枚举(field.list options/字典)→ 值域×count(V+3 wire:1 metadata+1 base+V 桶+1 isnull),桶按 count 降序取 topN(默认 10/上限 20),截断给 truncatedBuckets/bucketsTruncatedCount,null 单列 nullBucket;不可枚举或数值指标 → 本地扫描(coverage.mode=local-scan),数值桶 {key,count,nonNullCount,value} 按 value 降序、并列按 key,null 行进 nullBucket。filter.draftPolicy:count+groupBy 默认 includeDrafts:false 注入 sequenceStatus≠DRAFT(excluded)统一双口径;数值指标不默认排除(如实反映平台返回行);count 省略=平台默认(无条件下含草稿 included、带条件排草稿 excluded);显式 false 可强制排除。边界:临时问句用本工具;持久图表/看板用 report.chartdata,视图汇总列用 sumType,写时计算用 datarule type2。`;
11
+ return `临时计数与数值聚合(纯读)。count:runtime/query/list size:1 读 totalElements(服务端精确,不受 cap 1000 影响;带 filter +1 field.list 注入 propertyType)。sum/avg/min/max:field 必填且须已发布 propertyType=2(NUMERICAL),本地折叠——size:200 翻页至 cap 1000,null 行不进聚合、avg=sum/非 null 行数,nonNullCount=0 时 value:null;rowsScanned>=total 才 complete:true,否则 complete:false+missingCount+capNotice,**绝不外推**。groupBy 单列:count 时值域可枚举(field.list options/字典)→ 值域×count(V+3 wire),分桶 count 并发窗口 4、限流退化 2,结果与串行逐字段一致(wire.concurrency);桶按 count 降序取 topN(默认 10/上限 20),截断给 truncatedBuckets/bucketsTruncatedCount,null 单列 nullBucket;不可枚举或数值指标 → 本地扫描(local-scan),数值桶 {key,count,nonNullCount,value} 按 value 降序、并列按 key,null 行进 nullBucket。filter.draftPolicy:count+groupBy 默认 includeDrafts:false 注入 sequenceStatus≠DRAFT(excluded)统一双口径;数值指标不默认排除(如实反映平台返回行);count 省略=平台默认(无条件下含草稿 included、带条件排草稿 excluded);显式 false 可强制排除。边界:临时问句用本工具;持久图表/看板用 report.chartdata,视图汇总列用 sumType,写时计算用 datarule type2。`;
12
12
  }
13
13
  export function dataUpdateDescription() {
14
14
  const wire = RUNTIME_DATA_WIRE;
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { z } from "zod";
3
3
  import { FilterDslError, injectPropertyTypes, SIMPLE_OP_MAP, toQueryCondition } from "../data-list-filter.js";
4
+ import { DEFAULT_SCAN_CONCURRENCY, isThrottleClassError, mapWithConcurrency } from "../concurrency.js";
4
5
  import { ENDPOINTS } from "../endpoints.js";
5
6
  import { capabilityArg, environmentArg } from "../args.js";
6
7
  import { governedRead } from "../read.js";
@@ -1927,7 +1928,7 @@ export function registerRuntimeDataLane(tools) {
1927
1928
  return extractBizObjectPage(response.data).total;
1928
1929
  };
1929
1930
  const topN = args.topN ?? 10;
1930
- // 数值指标(sum/avg/min/max):平台无服务端聚合面 → 列投影 + size:200 翻页
1931
+ // 数值指标(sum/avg/min/max):平台无 group-by 面(数值有 /sum,受 GET_LIST 规则限制)→ 列投影 + size:200 翻页
1931
1932
  // 本地折叠至 cap 1000。null 行不进聚合;扫不完就给 complete:false + capNotice,
1932
1933
  // 绝不按扫描比例外推(与 count 的自由文本路径同一诚实口径)。
1933
1934
  if (numeric) {
@@ -2054,13 +2055,43 @@ export function registerRuntimeDataLane(tools) {
2054
2055
  const groupField = meta?.get(args.groupBy);
2055
2056
  const codes = groupField?.choiceCodes ?? [];
2056
2057
  if (groupField && Number.isInteger(groupField.type) && codes.length > 0) {
2057
- const baseTotal = await countAt();
2058
- const buckets = [];
2059
- for (const code of codes) {
2060
- const count = await countAt(aggregateLeafGroup(args.groupBy, groupField.type, "Eq", code));
2061
- buckets.push({ key: code, count });
2058
+ // R88 S1:值域×count 扇出(base + 每值域 Eq + IsNull)彼此独立,走有界
2059
+ // 并发(窗口 4)。fieldMeta() 已在前一行完成,绝不进并发窗口(metaCalls
2060
+ // 双计 + session 缓存);unit 结果按输入序重组,再走既有排序/topN——与
2061
+ // 串行逐字段一致,并发完成顺序不抖动输出。
2062
+ const groupBy = args.groupBy;
2063
+ const groupType = groupField.type;
2064
+ const units = [
2065
+ { kind: "base" },
2066
+ ...codes.map((code) => ({ kind: "bucket", code, leaf: aggregateLeafGroup(groupBy, groupType, "Eq", code) })),
2067
+ { kind: "null", leaf: aggregateLeafGroup(groupBy, groupType, "IsNull", "") },
2068
+ ];
2069
+ const leafOf = (unit) => (unit.kind === "base" ? undefined : unit.leaf);
2070
+ const scan = await mapWithConcurrency(units, DEFAULT_SCAN_CONCURRENCY, (unit) => countAt(leafOf(unit)));
2071
+ const values = new Array(units.length);
2072
+ scan.outcomes.forEach((outcome, index) => {
2073
+ if (outcome.ok)
2074
+ values[index] = outcome.value;
2075
+ });
2076
+ if (scan.failed.length > 0) {
2077
+ // 失败语义保持串行的 fail-fast:绝不返回「少一个桶」的部分结果。
2078
+ // 非限流类(业务拒绝)直接抛最低索引(不重试、不降级,也不被限流
2079
+ // 重试掩盖);全灭抛最低索引(确定性,等同串行);只有限流类且非
2080
+ // 全灭时,失败项串行重放一次(并发窗口的突发限流串行往往能过),
2081
+ // 仍失败抛最低索引。
2082
+ const businessFailure = scan.failed.find((failure) => !isThrottleClassError(failure.error));
2083
+ if (businessFailure !== undefined)
2084
+ throw businessFailure.error;
2085
+ if (scan.failed.length === units.length)
2086
+ throw scan.failed[0].error;
2087
+ // 串行重放是 unit 级重执行;wire.calls 仍按逻辑请求数,concurrency 直接
2088
+ // 复用窗口内 stats(与 workflow.list / rule.references 同口径)。
2089
+ for (const failure of scan.failed)
2090
+ values[failure.index] = await countAt(leafOf(units[failure.index]));
2062
2091
  }
2063
- const nullCount = await countAt(aggregateLeafGroup(args.groupBy, groupField.type, "IsNull", ""));
2092
+ const baseTotal = values[0];
2093
+ const buckets = codes.map((code, index) => ({ key: code, count: values[index + 1] }));
2094
+ const nullCount = values[units.length - 1];
2064
2095
  const sums = buckets.reduce((sum, bucket) => sum + bucket.count, 0);
2065
2096
  const unaccounted = baseTotal - sums - nullCount;
2066
2097
  buckets.sort((left, right) => right.count - left.count || left.key.localeCompare(right.key));
@@ -2077,7 +2108,11 @@ export function registerRuntimeDataLane(tools) {
2077
2108
  ...(unaccounted > 0 ? { unaccountedCount: unaccounted } : {}),
2078
2109
  coverage: { mode: "server-total", rowsScanned: 0, cap: AGGREGATE_CAP, complete: true },
2079
2110
  filter: draftFilter,
2080
- wire: { calls: metaCalls + 1 + codes.length + 1, plan: `1 metadata + 1 base + ${codes.length} buckets + 1 null` },
2111
+ wire: {
2112
+ calls: metaCalls + 1 + codes.length + 1,
2113
+ plan: `1 metadata + 1 base + ${codes.length} buckets + 1 null`,
2114
+ ...(units.length > 1 ? { concurrency: scan.stats } : {}),
2115
+ },
2081
2116
  };
2082
2117
  }
2083
2118
  // 自由文本/高基数:翻页取前 cap 行,只投影 groupBy 列本地计数;绝不按扫描比例外推。
@@ -73,8 +73,8 @@ const READ_SHAPES = {
73
73
  },
74
74
  // r80:计数/分组统计的读回面。notes 只显首条——把陷阱并进第一句。
75
75
  "data.aggregate": {
76
- keys: ["schemaCode", "metric", "field?", "value?", "count", "nonNullCount?", "nullCount?", "groupBy?", "total", "buckets:array<{key,count,nonNullCount?,value?}>", "nullBucket:{count,nonNullCount?,value?}", "truncatedBuckets", "bucketsTruncatedCount", "unaccountedCount?", "coverage:{mode,rowsScanned,cap,complete,missingCount?}", "filter:{draftPolicy,hint}", "wire:{calls,plan}", "capNotice?", "note?", "environmentFingerprint"],
77
- notes: ["计数用 total(服务端 totalElements,精确);分组是「值域×count」——buckets[].key 是字段存储值/code,null 单列 nullBucket;数值指标(metric=sum/avg/min/max+field)是本地折叠(cap 1000,null 行不进聚合、avg 分母排除 null),coverage.complete:false 时只覆盖已扫行,勿外推"],
76
+ keys: ["schemaCode", "metric", "field?", "value?", "count", "nonNullCount?", "nullCount?", "groupBy?", "total", "buckets:array<{key,count,nonNullCount?,value?}>", "nullBucket:{count,nonNullCount?,value?}", "truncatedBuckets", "bucketsTruncatedCount", "unaccountedCount?", "coverage:{mode,rowsScanned,cap,complete,missingCount?}", "filter:{draftPolicy,hint}", "wire:{calls,plan,concurrency?}", "capNotice?", "note?", "environmentFingerprint"],
77
+ notes: ["计数用 total(服务端 totalElements,精确);分组是「值域×count」——buckets[].key 是字段存储值/code,null 单列 nullBucket;分桶 count 扇出走有界并发(窗口 4,限流退化 2,见 wire.concurrency),桶按输入序重组后再排序,结果与串行逐字段一致;数值指标(metric=sum/avg/min/max+field)是本地折叠(cap 1000,null 行不进聚合、avg 分母排除 null),coverage.complete:false 时只覆盖已扫行,勿外推"],
78
78
  },
79
79
  "app.list": {
80
80
  keys: ["applications:array<{code,name,groupId?,modelCount}>", "applicationsCount", "omitted"],
@@ -25,7 +25,7 @@ const restfulQueryService = Object.freeze({
25
25
  "RESTFUL 方法 configJson 必需键:httpType(Post/Get/Put/Patch/Delete)、requestBodyType(Form-urlencoded/JSON/Text)、url、frontEndExtensionEnable(布尔)",
26
26
  "RESTFUL 每个输入/输出参数必须带 configJson.position ∈ QUERY_PARAMS/REQUEST_HEADER/REQUEST_BODY/PATH_PARAMS(URL_VARIABLE 被运行时拒 501007)",
27
27
  "每个输入/输出参数必须带 bizPropertyType(如 SHORT_TEXT/NUMERICAL)——缺它提交即被 bizservice-parameter-face-invalid 拒(r19-p7 首拒根因,2026-10-26 修正本配方)",
28
- "一次写只建一个方法;给既有服务加方法走 method.create(escape hatch)",
28
+ "一次 service.register 最多建一个方法(methodName 同时作为 code/name);要一次声明多个方法、或给既有服务加方法,用 intent services[].methods[](缺失 plan method.create、漂移 plan method.update),也可直接走低层 method.create",
29
29
  ],
30
30
  priorToolReferences: [
31
31
  { tool: "service.category.list", args: { environment }, purpose: "取服务分类 id(所属目录必填)" },
@@ -528,6 +528,7 @@ omc intent readback intent.yaml --env test # 解码回 intent 形状做等价
528
528
  ```
529
529
 
530
530
  - 顶层 `models[]` / `services[]`;`models[].{code,name,fields,datarules,rules,form,listview,workflow,onlinejs}`。
531
+ - 业务集成:`services[].method`(单方法,name 必须等于 code,随 `service.register`)与 `services[].methods[]`(多方法,name 可不同于 code;缺失方法 plan `method.create`、漂移 plan `method.update`,给既有服务加方法也用这里)互斥。
531
532
  - `intent apply` 既可以吃 `plan` 文件,也可以直接吃 YAML(`omc intent apply intent.yaml --env <env>`,自动编译);大 plan 会自动外置,回 `planFile`。
532
533
  - **幂等收敛**:已达标环境重跑 plan/apply → 零变更、零重复创建。
533
534
  - 显式缺席(删除):`models[].absent:true` 删整模型、`fields[].absent:true` 删单字段、`listview.absent:true` 删列表视图、`datarules[].absent:true` 删数据规则;plan 的 `riskClass` 升为 `destructive`,`cleanup` 逐项列出。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.85",
3
+ "version": "0.6.86",
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.85",
59
+ "omc-core": "0.6.86",
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.85"
77
+ "@stalfh233/omc-fake-platform": "0.6.86"
78
78
  }
79
79
  }
@@ -192,6 +192,7 @@ only the section for the capability you need —
192
192
  - **能做哪些事**:业务服务与方法注册(RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA/SOAP)、服务清单(按分类/关键词,凭据不回显)、方法增改删、分类/连接池、导入导出、设计器测试、调用日志(`h_log_biz_service`:params/result/状态/耗时,按单据/服务/方法/时间窗查,无过滤 fail-closed)。
193
193
  - **工具**:`service.list`、`service.get`、`method.list`、`method.get`、`method.update`、`method.create`、`method.delete`、`service.category.list`、`service.category.create`、`service.category.update`、`service.category.delete`、`service.dbconnpool.list`、`service.dbconnpool.create`、`service.dbconnpool.update`、`service.dbconnpool.delete`、`service.adapter_config`、`service.table_list`、`service.table_sql`、`service.register`、`service.update`、`service.delete`、`service.export`、`service.check`、`service.import`、`method.test`、`servicelog.search`
194
194
  - **recipe**:`omc describe service.register --example restful-query-service`
195
+ - **intent**:`services[].method`(单方法,name==code)与 `services[].methods[]`(多方法,name 可不同于 code)互斥;`methods[]` 对缺失方法 plan `method.create`、漂移 plan `method.update`,因此给既有服务加方法无需 escape hatch。
195
196
  - **边界 / 陷阱**:方法 `configJson` 走 AES-128-ECB;**二开接口 = 扩展模块写 REST 接口 + RESTFUL 服务指向它**(页面/规则引用);RESTFUL/DATA_SQL 绑定前须带适配器必需配置(否则是注册壳)。排查「规则到底传了什么参数给接口」用 `servicelog.search`(`bizObjectId`/`schemaCode` 是客户端匹配,`code`/`methodName` 为 LIKE 包含、逗号=精确 IN;params 平台入库上限 2000 字符)。
196
197
 
197
198
  ## 报表 `report`