@stalfh233/omc-cli 0.8.31 → 0.8.33
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/dist/arg-vocabulary.js +223 -0
- package/dist/artifact-cmd.js +443 -0
- package/dist/batch-call.js +56 -3
- package/dist/call-command.js +70 -0
- package/dist/call-execute.js +228 -0
- package/dist/call-input.js +557 -0
- package/dist/call-output.js +240 -0
- package/dist/cli.js +23 -1360
- package/dist/command-transport.js +4 -1
- package/dist/field-add.js +2 -1
- package/dist/form-support.js +17 -4
- package/dist/intent/plan-apply.js +14 -24
- package/dist/lanes/datarule.js +21 -0
- package/dist/lanes/field.js +31 -0
- package/dist/lanes/list-view-shapes.js +8 -1
- package/dist/lanes/list-view.js +64 -2
- package/dist/lanes/runtime-data/aggregate-support.js +209 -0
- package/dist/lanes/runtime-data/aggregate.js +679 -0
- package/dist/lanes/runtime-data/field-options.js +52 -0
- package/dist/lanes/runtime-data/lane.js +4 -0
- package/dist/lanes/runtime-data/record-delete.js +419 -0
- package/dist/lanes/runtime-data/record-read.js +984 -0
- package/dist/lanes/runtime-data/record-write.js +562 -0
- package/dist/lanes/runtime-data/registration.js +22 -0
- package/dist/lanes/runtime-data/shapes.js +594 -0
- package/dist/lanes/runtime-data/submission.js +1293 -0
- package/dist/lanes/runtime-data/write-support.js +875 -0
- package/dist/lanes/runtime-data-contract.js +1 -1
- package/dist/lanes/runtime-data.js +10 -5556
- package/dist/lanes/workflow/approval-ops.js +983 -0
- package/dist/lanes/workflow/instance-read.js +284 -0
- package/dist/lanes/workflow/lifecycle-write.js +1499 -0
- package/dist/lanes/workflow/permissions.js +571 -0
- package/dist/lanes/workflow/recovery.js +361 -0
- package/dist/lanes/workflow/registration.js +14 -0
- package/dist/lanes/workflow/shapes.js +811 -0
- package/dist/lanes/workflow/template-fetch.js +197 -0
- package/dist/lanes/workflow/template-merge.js +1351 -0
- package/dist/lanes/workflow/template-read.js +327 -0
- package/dist/lanes/workflow.js +11 -6312
- package/dist/model-scaffold.js +3 -1
- package/dist/path-projection.js +27 -6
- package/dist/read-projection.js +442 -0
- package/dist/read.js +40 -335
- package/dist/rollback.js +17 -23
- package/dist/runtime-support.js +1 -1
- package/dist/verification.js +39 -0
- package/dist/write-coordinator.js +152 -0
- package/dist/write-outcome.js +295 -0
- package/dist/write.js +34 -115
- package/package.json +3 -3
- package/skills/omc-refusals.md +1 -1
- package/skills/omc-start-here.md +3 -3
|
@@ -5,6 +5,7 @@ import { resolve } from "node:path";
|
|
|
5
5
|
import { CLI_DEFAULT_OUTPUT_BYTES, CLI_MAX_OUTPUT_BYTES, createArtifact, isWithinRoot, readArtifact } from "./artifacts.js";
|
|
6
6
|
import { CLI_EXIT_CODES, classifyResult, envelope, errorEnvelope } from "./cli-contract.js";
|
|
7
7
|
import { writeEnvelope, outputOptions } from "./cli-output.js";
|
|
8
|
+
import { fitsStdoutBudget } from "./read-projection.js";
|
|
8
9
|
const UNCERTAIN_NEXT_ACTION = "read back the requestId before retrying; retry only after the outcome is established";
|
|
9
10
|
/**
|
|
10
11
|
* Run a CLI action inside the transport band: validate the budget up front (a
|
|
@@ -78,7 +79,9 @@ export function boundResult(result, budget) {
|
|
|
78
79
|
const serialized = JSON.stringify(sanitized);
|
|
79
80
|
if (outputOptions().outFile)
|
|
80
81
|
return sanitized;
|
|
81
|
-
|
|
82
|
+
// 预算判定复用 read-projection.ts 的唯一字节判定(三层投影的最后一层;
|
|
83
|
+
// 前两层——读面 artifact 与 --jq 路径选择——都已在此处之前完成)。
|
|
84
|
+
if (fitsStdoutBudget(serialized, budget))
|
|
82
85
|
return sanitized;
|
|
83
86
|
const artifact = createArtifact(artifactRoot(), JSON.stringify(sanitized, null, 2) + "\n");
|
|
84
87
|
return { status: sanitized.status ?? "ok", truncated: true, artifactId: artifact.artifactId, sha256: artifact.sha256, bytes: Buffer.byteLength(serialized), fetch: artifactFetchHint(artifact.artifactId) };
|
package/dist/field-add.js
CHANGED
|
@@ -185,7 +185,8 @@ export async function cmdFieldAdd(args, contextForTest) {
|
|
|
185
185
|
inputJson = readFileSync(assertSafeInputPath(root, fieldsFile, "--fields-file"), "utf8");
|
|
186
186
|
}
|
|
187
187
|
catch (error) {
|
|
188
|
-
|
|
188
|
+
// F1(0.8.32):与 --args-file / model-scaffold 同语气——先给 stdin。
|
|
189
|
+
return invalid(`--fields-file 读取失败:${error instanceof Error ? error.message : String(error)}${/must be inside the configuration root/.test(error instanceof Error ? error.message : String(error)) ? "。免落盘替代:`--fields -` 从 stdin 读 JSON(--fields - < <文件>);或把参数文件放到配置根内(如配置根/args.json)再用 --fields-file 引用" : ""}`);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
if (inputJson === undefined)
|
package/dist/form-support.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { wireCall, wireRows, WireError } from "./wire.js";
|
|
2
2
|
import { ENDPOINTS } from "./endpoints.js";
|
|
3
3
|
import { decodeJsonObjectColumn } from "./json-column.js";
|
|
4
|
+
import { verificationPartial } from "./verification.js";
|
|
4
5
|
import { ToolRefusalError } from "./tool-types.js";
|
|
5
6
|
import { FIELD_CONTROL_TYPES, childColumnsOf, SYSTEM_FIELD_CODES, fieldControlOptions, relationDisplayField, relationMappings, } from "./field-families.js";
|
|
6
7
|
import { deriveControlOptions } from "./capability-shape.js";
|
|
@@ -1356,15 +1357,27 @@ export async function childColumnsMissingFromForm(session, args) {
|
|
|
1356
1357
|
return missing;
|
|
1357
1358
|
}
|
|
1358
1359
|
/** 发布面缺子表列时的一句诊断(write 与 dry-run 同一句)。 */
|
|
1359
|
-
export const CHILD_COLUMNS_NOT_IN_FORM_NOTE = "
|
|
1360
|
+
export const CHILD_COLUMNS_NOT_IN_FORM_NOTE = "子表字段已发布,表单 Sheet201 columns 无此列——页面不可见(成功≠可见)。form.publish 加 bindNewChildColumns:true 一步绑定后发布(不动其它控件/布局);补 fieldCodes/布局才用 configure_form";
|
|
1360
1361
|
/** 发布面缺子表列时的回执片段(写路径 / already-published 短路 / dry-run 共用一份形状)。 */
|
|
1361
|
-
function childColumnsGapReadback(gaps, schemaCode, sheetCode
|
|
1362
|
+
function childColumnsGapReadback(gaps, schemaCode, sheetCode,
|
|
1363
|
+
// 预览(dry-run)没有发布动作:只给旧键,不冒充「已发布」的验收等级。
|
|
1364
|
+
phase = "written") {
|
|
1362
1365
|
if (gaps === undefined || gaps.length === 0)
|
|
1363
1366
|
return {};
|
|
1367
|
+
// F3(0.8.32):form.publish 自己就能一步绑定(bindNewChildColumns:true,与
|
|
1368
|
+
// field.publish 的教学一致),旧 nextCommand 指向 configure_form 的两次调用。
|
|
1369
|
+
const nextCommand = `omc call form.publish --args '${JSON.stringify({ schemaCode, ...(sheetCode !== schemaCode ? { sheetCode } : {}), bindNewChildColumns: true })}'`;
|
|
1364
1370
|
return {
|
|
1365
1371
|
childColumnsNotInForm: gaps,
|
|
1366
1372
|
childColumnsNote: CHILD_COLUMNS_NOT_IN_FORM_NOTE,
|
|
1367
|
-
nextCommand
|
|
1373
|
+
nextCommand,
|
|
1374
|
+
// 统一验收等级(0.8.33):已发布 ≠ 页面可见。旧 childColumnsNotInForm/
|
|
1375
|
+
// childColumnsNote/nextCommand 原样保留,这里补结构投影。
|
|
1376
|
+
...(phase === "written"
|
|
1377
|
+
? {
|
|
1378
|
+
verification: verificationPartial("已发布,但子表列未绑定到表单——业务页不可见(配置等价 ≠ 运行面可用)。", { command: nextCommand, manual: "门户打开该表单,确认子表控件里能看到这些列" }),
|
|
1379
|
+
}
|
|
1380
|
+
: {}),
|
|
1368
1381
|
};
|
|
1369
1382
|
}
|
|
1370
1383
|
/**
|
|
@@ -1417,7 +1430,7 @@ export async function lintFormPublishReadOnly(session, args) {
|
|
|
1417
1430
|
: "没有待绑定的子表列",
|
|
1418
1431
|
}
|
|
1419
1432
|
: {}),
|
|
1420
|
-
...childColumnsGapReadback(childColumnGaps, args.schemaCode, sheetCode),
|
|
1433
|
+
...childColumnsGapReadback(childColumnGaps, args.schemaCode, sheetCode, "planned"),
|
|
1421
1434
|
note: willBindChildColumns
|
|
1422
1435
|
? "降级门与真写同一函数;bindNewChildColumns 会先增量绑定这些子表列,因此真写不会短路(会改发布面)"
|
|
1423
1436
|
: "降级门与真写同一函数;alreadyPublished:true 时真写会短路(不改发布面)",
|
|
@@ -12,7 +12,7 @@ import { SessionManager } from "../session-manager.js";
|
|
|
12
12
|
import { ConfigStore, defaultPaths } from "../config-store.js";
|
|
13
13
|
import { buildToolRegistry } from "../tools.js";
|
|
14
14
|
import { executeChangesBatch } from "../lanes/apply-changes.js";
|
|
15
|
-
import {
|
|
15
|
+
import { writeCoordinator, WriteLockConflictError } from "../write-coordinator.js";
|
|
16
16
|
import { wireCall, WireError } from "../wire.js";
|
|
17
17
|
import { ENDPOINTS } from "../endpoints.js";
|
|
18
18
|
import { extractBizObjectPage } from "../lanes/runtime-data.js";
|
|
@@ -497,27 +497,10 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
497
497
|
// `--wait` mirrors `omc call --wait`: bound the retry inside the CLI instead
|
|
498
498
|
// of forcing the caller to spend a round trip per conflict. Default stays 0
|
|
499
499
|
// (fail fast, structured refusal) — the opt-in is what makes it safe for
|
|
500
|
-
// non-replayable batches.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
while (!lock.held && Date.now() < deadline) {
|
|
505
|
-
await new Promise((resolve) => setTimeout(resolve, Math.min(200, Math.max(0, deadline - Date.now()))));
|
|
506
|
-
lock = await acquireWriteLock(plan.environment);
|
|
507
|
-
}
|
|
508
|
-
if (!lock.held) {
|
|
509
|
-
const conflict = {
|
|
510
|
-
status: "refused",
|
|
511
|
-
blocker: "write-lock-held",
|
|
512
|
-
environment: plan.environment,
|
|
513
|
-
owner: lock.owner,
|
|
514
|
-
recovery: lock.recovery,
|
|
515
|
-
message: lock.recovery[0],
|
|
516
|
-
};
|
|
517
|
-
console.error(`write lock conflict: ${JSON.stringify(lock.owner)}`);
|
|
518
|
-
return emit(conflict);
|
|
519
|
-
}
|
|
520
|
-
try {
|
|
500
|
+
// non-replayable batches. The acquire/wait/refusal policy itself lives in
|
|
501
|
+
// write-coordinator (W35); this function only supplies the intent-shaped
|
|
502
|
+
// refusal receipt the CLI has always emitted.
|
|
503
|
+
const applyPlan = async () => {
|
|
521
504
|
const context = makeToolContext({ sessions: new SessionManager(new ConfigStore(defaultPaths())) });
|
|
522
505
|
const session = await context.sessions.session(plan.environment);
|
|
523
506
|
if (session.environmentFingerprint() !== plan.environmentFingerprint)
|
|
@@ -652,9 +635,16 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
652
635
|
// refused / uncertain outcome already reports its own status and must not
|
|
653
636
|
// be papered over by a second read.
|
|
654
637
|
return emit(result.status === "ok" ? await confirmReadback(delivered) : delivered);
|
|
638
|
+
};
|
|
639
|
+
try {
|
|
640
|
+
return await writeCoordinator.run({ environment: plan.environment, tool: "intent.apply", waitMs: options.waitMs ?? 0, mode: "intent" }, applyPlan);
|
|
655
641
|
}
|
|
656
|
-
|
|
657
|
-
|
|
642
|
+
catch (error) {
|
|
643
|
+
if (!(error instanceof WriteLockConflictError))
|
|
644
|
+
throw error;
|
|
645
|
+
if (error.conflict.stderr !== undefined)
|
|
646
|
+
console.error(error.conflict.stderr);
|
|
647
|
+
return emit(error.conflict.receipt);
|
|
658
648
|
}
|
|
659
649
|
}
|
|
660
650
|
//# sourceMappingURL=plan-apply.js.map
|
package/dist/lanes/datarule.js
CHANGED
|
@@ -5,6 +5,7 @@ import { capabilityArg, environmentArg } from "../args.js";
|
|
|
5
5
|
import { governedRead } from "../read.js";
|
|
6
6
|
import { ToolRefusalError } from "../tool-types.js";
|
|
7
7
|
import { writeTool } from "../write.js";
|
|
8
|
+
import { verificationConfigOnly, verificationUnverified } from "../verification.js";
|
|
8
9
|
import { decodeJsonColumn, JSON_COLUMN_PASSTHROUGH } from "../json-column.js";
|
|
9
10
|
import { defineTool } from "../tool-types.js";
|
|
10
11
|
import { resolveDataRuleRow } from "../identity.js";
|
|
@@ -1037,6 +1038,17 @@ export function registerDataRuleLane(tools) {
|
|
|
1037
1038
|
runtimeScope: args.checkType === 5 ? "server" : args.checkType !== undefined ? "portal-only" : "unknown",
|
|
1038
1039
|
// 缺 checkType 时执行面未知:不要假装 enforcedServerSide:false。
|
|
1039
1040
|
...(args.checkType !== undefined ? { enforcedServerSide: args.checkType === 5 } : {}),
|
|
1041
|
+
// 统一验收等级(0.8.33):runtimeScope 是旧字段,这里补同一句话的
|
|
1042
|
+
// 结构投影。checkType 5 走服务端重复校验,但本次没有提交数据,
|
|
1043
|
+
// 只能算 unverified;其余 type1 只在门户提交管线执行,REST 实测放行。
|
|
1044
|
+
verification: args.checkType === 5
|
|
1045
|
+
? verificationUnverified("rest", "仅证明数据规则配置已保存;checkType 5 是服务端重复校验,在 REST data.submit 路径执行,但本次未提交数据取证。", { command: `omc call datarule.list --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, dataRuleType: 1 })}'` })
|
|
1046
|
+
: args.checkType !== undefined
|
|
1047
|
+
? verificationConfigOnly("portal", "仅证明数据规则配置已保存(datarule.list 回读一致),未证明 REST data.submit 执行该校验——type1 非 checkType 5 在门户前端提交管线执行,REST 实测放行违规值。", {
|
|
1048
|
+
command: `omc call datarule.list --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, dataRuleType: 1 })}'`,
|
|
1049
|
+
manual: "门户表单提交一次违规数据,核对校验是否拦截(REST data.submit 不执行该校验)",
|
|
1050
|
+
})
|
|
1051
|
+
: verificationUnverified("none", "仅证明数据规则配置已保存;缺 checkType,执行面未知(REST/门户均未取证)。"),
|
|
1040
1052
|
executionWarning: dataRuleExecutionWarning(args.checkType),
|
|
1041
1053
|
// P1(探针 H F3,复核 2026-11-27):声明 validateHiddenProperties
|
|
1042
1054
|
// 的行**不抑制**提示——该键 2.1.5 独有,8.6.26/8.7 不执行;只按
|
|
@@ -1141,6 +1153,15 @@ export function registerDataRuleLane(tools) {
|
|
|
1141
1153
|
return {
|
|
1142
1154
|
runtimeScope: effectiveCheckType === 5 ? "server" : effectiveCheckType !== undefined ? "portal-only" : "unknown",
|
|
1143
1155
|
...(effectiveCheckType !== undefined ? { enforcedServerSide: effectiveCheckType === 5 } : {}),
|
|
1156
|
+
// 统一验收等级(0.8.33):与 create 同一执行面口径,按生效 checkType 报。
|
|
1157
|
+
verification: effectiveCheckType === 5
|
|
1158
|
+
? verificationUnverified("rest", "仅证明数据规则配置已保存;checkType 5 是服务端重复校验,在 REST data.submit 路径执行,但本次未提交数据取证。", { command: `omc call datarule.list --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, dataRuleType: 1 })}'` })
|
|
1159
|
+
: effectiveCheckType !== undefined
|
|
1160
|
+
? verificationConfigOnly("portal", "仅证明数据规则配置已保存(datarule.list 回读一致),未证明 REST data.submit 执行该校验——type1 非 checkType 5 在门户前端提交管线执行,REST 实测放行违规值。", {
|
|
1161
|
+
command: `omc call datarule.list --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, dataRuleType: 1 })}'`,
|
|
1162
|
+
manual: "门户表单提交一次违规数据,核对校验是否拦截(REST data.submit 不执行该校验)",
|
|
1163
|
+
})
|
|
1164
|
+
: verificationUnverified("none", "仅证明数据规则配置已保存;生效 checkType 不可得,执行面未知(REST/门户均未取证)。"),
|
|
1144
1165
|
executionWarning: dataRuleExecutionWarning(effectiveCheckType),
|
|
1145
1166
|
};
|
|
1146
1167
|
})()
|
package/dist/lanes/field.js
CHANGED
|
@@ -5,6 +5,7 @@ import { aggregationSelfSchemaMessage, aggregationTargetsOwnSchema, choicesArg,
|
|
|
5
5
|
import { capabilityArg, environmentArg } from "../args.js";
|
|
6
6
|
import { governedRead } from "../read.js";
|
|
7
7
|
import { writeTool } from "../write.js";
|
|
8
|
+
import { verificationConfigOnly } from "../verification.js";
|
|
8
9
|
import { decodeJsonColumn, decodeJsonObjectColumn, JSON_COLUMN_NULL_COALESCE, JSON_COLUMN_PASSTHROUGH } from "../json-column.js";
|
|
9
10
|
import { syncFormConditionDataRules } from "./datarule.js";
|
|
10
11
|
import { FORM_CONDITION_OPTION_KEYS } from "./datarule-protocol.js";
|
|
@@ -417,6 +418,10 @@ function hasRelationMappings(options) {
|
|
|
417
418
|
* 因此「配置对不对」看 options.mappings,「值会不会回填」看写入面走哪条路。
|
|
418
419
|
*/
|
|
419
420
|
const FIELD_MAPPING_RUNTIME_NOTE = "映射只在门户选值时回填:CLI data.save(/api/runtime/form/save)不跑 options.mappings,快照列需调用方自填;配置正确性以字段行 options.mappings 为准。";
|
|
421
|
+
/** 统一验收等级(0.8.33):关联映射的旧说明(mappingRuntimeNote)原样保留,这里给结构投影。 */
|
|
422
|
+
function fieldMappingVerification(schemaCode, code) {
|
|
423
|
+
return verificationConfigOnly("portal", "仅证明字段映射配置已保存(字段行 options.mappings 读回一致),未证明 REST 写会回填——data.save(/api/runtime/form/save)不跑 options.mappings,快照列需调用方自填。", { command: `omc call field.get --env <env> --args '${JSON.stringify({ schemaCode, code })}'` });
|
|
424
|
+
}
|
|
420
425
|
/**
|
|
421
426
|
* `name_i18n` is a JSON locale map. When every locale value equals the display
|
|
422
427
|
* `name` there is no translation to convey, so echoing the map on every field of
|
|
@@ -828,6 +833,11 @@ export function registerFieldLane(tools) {
|
|
|
828
833
|
...(selector.length > 0 ? { selected: selector } : {}),
|
|
829
834
|
...(args.all !== true ? { businessOnly: true } : {}),
|
|
830
835
|
...(mappingRuntimeNote !== undefined ? { mappingRuntimeNote } : {}),
|
|
836
|
+
...(mappingRuntimeNote !== undefined
|
|
837
|
+
? {
|
|
838
|
+
verification: verificationConfigOnly("portal", "仅证明字段映射配置已读回(字段行 options.mappings),未证明 REST 写会回填——data.save(/api/runtime/form/save)不跑 options.mappings,快照列需调用方自填。", { manual: "门户表单选择关联值,核对映射是否回填;REST data.save 不跑 options.mappings" }),
|
|
839
|
+
}
|
|
840
|
+
: {}),
|
|
831
841
|
fields: projected,
|
|
832
842
|
// 券商 issue 1.4(2026-10-27):默认面空清单曾被误读成「模型没有字段」。
|
|
833
843
|
// 空清单要自己解释三种可能,别让 agent 二次试错;发布面(published:true)
|
|
@@ -868,6 +878,19 @@ export function registerFieldLane(tools) {
|
|
|
868
878
|
if (args.full === true && Array.isArray(result.fields)
|
|
869
879
|
&& result.fields.some((field) => field.options !== undefined))
|
|
870
880
|
return result;
|
|
881
|
+
// 0.8.33 回归(w34):`verification`(映射运行期说明)把映射模型的原生
|
|
882
|
+
// 结果从 <2048B 推过 diet 门,本 compact 于是**第一次真正生效**——但它只
|
|
883
|
+
// 放行 `inventory` / `full`,把 `code` / `fields` 选择器当清单投影,
|
|
884
|
+
// `options` 被剥成 `optionsPresent`。回执自己的 hint 却在教「字段详情用
|
|
885
|
+
// code/fields 选择器」,调用方照做后读不到 `options.mappings`
|
|
886
|
+
// (`field-relation-mapping-sources` A1 直接红)。
|
|
887
|
+
// 选择器是**显式详情请求**,与 full 同级:原样返回,体积由 read 层的
|
|
888
|
+
// 外置兜底。不要改成「字节/行数阈值」——那会让无关字段的增长再次悄悄
|
|
889
|
+
// 触发同一回归。
|
|
890
|
+
const selectorRequested = (typeof args.code === "string" && args.code.length > 0 && !isRequiredAlternativePlaceholder(args.code))
|
|
891
|
+
|| (Array.isArray(args.fields) && args.fields.length > 0);
|
|
892
|
+
if (selectorRequested)
|
|
893
|
+
return result;
|
|
871
894
|
const fields = Array.isArray(result.fields) ? result.fields : [];
|
|
872
895
|
return {
|
|
873
896
|
schemaCode: result.schemaCode,
|
|
@@ -1051,6 +1074,10 @@ export function registerFieldLane(tools) {
|
|
|
1051
1074
|
// 探针 P F5(0.8.22):写回执回显**生效值**(scale/format/mappings 等只在
|
|
1052
1075
|
// options 里的语义),省掉一次 field.get 才能核对单位/精度/映射方向。
|
|
1053
1076
|
...(createdOptions !== undefined ? { options: createdOptions } : {}),
|
|
1077
|
+
// 统一验收等级(0.8.33):关联映射配置等价 ≠ REST 写回填。
|
|
1078
|
+
...(hasRelationMappings(createdOptions) || hasRelationMappings(prepared.options)
|
|
1079
|
+
? { verification: fieldMappingVerification(args.schemaCode, args.code) }
|
|
1080
|
+
: {}),
|
|
1054
1081
|
...(prepared.normalized ? { normalized: prepared.normalized } : {}),
|
|
1055
1082
|
...(textLike
|
|
1056
1083
|
? {
|
|
@@ -1986,6 +2013,10 @@ async function runFieldUpdate(session, args) {
|
|
|
1986
2013
|
}
|
|
1987
2014
|
: {}),
|
|
1988
2015
|
...(storedOptions !== undefined && storedOptions !== null ? { options: storedOptions } : {}),
|
|
2016
|
+
// 统一验收等级(0.8.33):关联映射配置等价 ≠ REST 写回填。
|
|
2017
|
+
...(hasRelationMappings(storedOptions) || hasRelationMappings(prepared.options)
|
|
2018
|
+
? { verification: fieldMappingVerification(args.schemaCode, args.code) }
|
|
2019
|
+
: {}),
|
|
1989
2020
|
...(dictionarySynced !== undefined ? { dictionarySynced } : {}),
|
|
1990
2021
|
...(formConditionSync !== undefined ? { formConditionSync } : {}),
|
|
1991
2022
|
...(formConditionSyncError !== undefined ? { formConditionSync: { error: formConditionSyncError } } : {}),
|
|
@@ -2,6 +2,7 @@ export { QUERY_ACTION_TYPE, QUERY_ACTION_RELATIVE, validateButtonActionConfig }
|
|
|
2
2
|
import { QUERY_ACTION_TYPE, QUERY_ACTION_RELATIVE, validateButtonActionConfig, wireEnum } from "omc-core/list-view-wire";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ToolRefusalError } from "../tool-types.js";
|
|
5
|
+
import { normalizeConceptValue } from "../arg-vocabulary.js";
|
|
5
6
|
import { decodeJsonColumn, encodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
|
|
6
7
|
import { FIELD_PROPERTY_TYPES } from "../field-families.js";
|
|
7
8
|
/**
|
|
@@ -135,7 +136,13 @@ export const QUERY_PRESENTATION_TYPE = {
|
|
|
135
136
|
* ModelManagementFacadeImpl.resolveRelations and overwrites any input.
|
|
136
137
|
*/
|
|
137
138
|
export const PRESENTATION_FIELDS = ["htmlJson", "actionsJson", "columnsJson", "queryViewDataSource", "schemaRelations", "options"];
|
|
138
|
-
|
|
139
|
+
// 值归一:合法值是 ASC|DESC(SortDirectionType 数字 1/2),调用方按别的面习惯
|
|
140
|
+
// 写 `desc`/`Desc`。归一表在 arg-vocabulary(`listview.sort.direction`:asc/desc
|
|
141
|
+
// + 大小写折叠),这里只做 zod 层 preprocess——枚举本身不放宽,拒绝文案仍列
|
|
142
|
+
// ASC|DESC(zod 的 invalid_enum_value 带 options,见 tool-types 的中文渲染)。
|
|
143
|
+
export const directionArg = z
|
|
144
|
+
.preprocess((value) => normalizeConceptValue("listview.sort.direction", value), z.enum(["ASC", "DESC"]))
|
|
145
|
+
.describe("SortDirectionType; sent numeric ASC(1)/DESC(2)");
|
|
139
146
|
export const displayTypeArg = z
|
|
140
147
|
.enum(["INPUT", "RADIO", "CHECKBOX", "SELECT", "RANGE"])
|
|
141
148
|
.describe("门户筛选控件(不是字段类型):文本→INPUT;数值/日期/时间→RANGE;单选/复选/下拉/下拉多选→SELECT(需要复选组时才显式 CHECKBOX)。默认按 8.6.34 前端 typeFormat;2.1.5 未采样,见 docs/platform-contracts/2.1-delta.md:313-319");
|
package/dist/lanes/list-view.js
CHANGED
|
@@ -4,9 +4,12 @@ import { ENDPOINTS } from "../endpoints.js";
|
|
|
4
4
|
import { capabilityArg, environmentArg } from "../args.js";
|
|
5
5
|
import { governedRead, compactReadback } from "../read.js";
|
|
6
6
|
import { writeTool } from "../write.js";
|
|
7
|
+
import { verificationConfigOnly, verificationUnverified } from "../verification.js";
|
|
7
8
|
import { encodeJsonColumn } from "../json-column.js";
|
|
8
9
|
import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
|
|
9
10
|
import { wireCall, wireRows, WireError } from "../wire.js";
|
|
11
|
+
import { jsonBytes } from "../support.js";
|
|
12
|
+
import { READ_DIET_INLINE_BYTES } from "../read-projection.js";
|
|
10
13
|
import { QUERY_ACTION_TYPE } from "omc-core/list-view-wire";
|
|
11
14
|
import { resolveModelTreeNode } from "./model.js";
|
|
12
15
|
import { NUMERICAL_FORMAT_DECIMALS, SYSTEM_FIELD_CODES, canonicalNumericalFormat } from "../field-families.js";
|
|
@@ -39,6 +42,40 @@ const DATA_LIST_OP_BY_FILTER_TYPE = {
|
|
|
39
42
|
Between: "between",
|
|
40
43
|
NotBetween: "notbetween",
|
|
41
44
|
};
|
|
45
|
+
function columnDetail(column, sumType) {
|
|
46
|
+
return {
|
|
47
|
+
propertyCode: column.propertyCode,
|
|
48
|
+
...(column.propertyType !== undefined ? { propertyType: column.propertyType } : {}),
|
|
49
|
+
...(column.displayFormat !== undefined ? { displayFormat: column.displayFormat } : {}),
|
|
50
|
+
...(column.visible !== undefined ? { visible: column.visible } : {}),
|
|
51
|
+
sumType: sumType ?? null,
|
|
52
|
+
...(column.width !== undefined ? { width: column.width } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* W36K(0.8.34):`columnsDetailed` 的「不让逃逸键自己改判 diet」规则。
|
|
57
|
+
*
|
|
58
|
+
* `columns` 在 `CODE_LIST_KEYS` 里,默认读面 >2048B 会被折成裸码表,丢
|
|
59
|
+
* displayFormat/visible/sumType/width——与 0.8.30 的 `sortsDetailed`/
|
|
60
|
+
* `conditionsDetailed` 同形,给一个不折叠的详细键。但列对象在内联档本来就在
|
|
61
|
+
* `columns` 里,无条件加一份详情会把临界视图(实测:5 列视图 1638B、按钮读
|
|
62
|
+
* 1824B)推过 `READ_DIET_INLINE_BYTES`,把 `buttons`/`conditions` 一起折掉,
|
|
63
|
+
* 反而丢按钮脚本等正文。所以:
|
|
64
|
+
* - 带上后仍在预算内 → 内联面也带(小视图能直接看详情);
|
|
65
|
+
* - 结果本来就要外置 → 带上(折面唯一的详情来源);
|
|
66
|
+
* - 只有「加它才会翻成折面」→ 不带(内联 columns 已是完整列对象,零信息损失)。
|
|
67
|
+
* 阈值用 `read-projection.ts` 的共享常量,不另立第二真相源。listview.get 的结果
|
|
68
|
+
* 里没有 items/logs/triggers,`smallRowSet` 恒 false,故这里的字节判据与
|
|
69
|
+
* `decideReadExternalization` 一致。
|
|
70
|
+
*/
|
|
71
|
+
function withColumnsDetailedOr(result, columnsDetailed) {
|
|
72
|
+
if (columnsDetailed.length === 0)
|
|
73
|
+
return result;
|
|
74
|
+
if (jsonBytes(result) > READ_DIET_INLINE_BYTES)
|
|
75
|
+
return { ...result, columnsDetailed };
|
|
76
|
+
const withDetailed = { ...result, columnsDetailed };
|
|
77
|
+
return jsonBytes(withDetailed) <= READ_DIET_INLINE_BYTES ? withDetailed : result;
|
|
78
|
+
}
|
|
42
79
|
/**
|
|
43
80
|
* r62a-F5 / r61 a-F14:列汇总(sumType)真值在呈现层 queryPresentation.columnsJson
|
|
44
81
|
* ——queryColumns 列树不回它。listview.get 与 listview.configure 的读回共用这个
|
|
@@ -550,6 +587,11 @@ export function registerListViewLane(tools) {
|
|
|
550
587
|
visible: column.visible,
|
|
551
588
|
sumType: sumTypeByCode.get(String(column.propertyCode)) ?? column.sumType ?? null,
|
|
552
589
|
}));
|
|
590
|
+
// 0.8.34(W36K):列面也补 detailed 逃逸键。`columns` 在 CODE_LIST_KEYS 里,
|
|
591
|
+
// 默认读面 >2048B 会被折成裸码表,displayFormat/visible/sumType/width 全丢;
|
|
592
|
+
// 与 0.8.30 的 sortsDetailed/conditionsDetailed 同形。无值的键省略(undefined),
|
|
593
|
+
// `sumType` 保留 null(= 不汇总,是真值不是缺席);`options` 一律不内联。
|
|
594
|
+
const columnsDetailed = readArray(model, "queryColumns").map((column) => columnDetail(column, sumTypeByCode.get(String(column.propertyCode)) ?? column.sumType));
|
|
553
595
|
// Direction is decoded to the enum NAME (ASC/DESC) — the same shape
|
|
554
596
|
// `listview.configure` reads back, so a get→configure round-trip does not
|
|
555
597
|
// surprise the caller with a raw numeric index (dogfood R2 round17b).
|
|
@@ -577,7 +619,7 @@ export function registerListViewLane(tools) {
|
|
|
577
619
|
const queryLayer = Array.isArray(model.queryLayer) && model.queryLayer.length > 0
|
|
578
620
|
? queryLayerSummary(model.queryLayer)
|
|
579
621
|
: undefined;
|
|
580
|
-
return {
|
|
622
|
+
return withColumnsDetailedOr({
|
|
581
623
|
schemaCode: args.schemaCode,
|
|
582
624
|
code,
|
|
583
625
|
present: true,
|
|
@@ -655,20 +697,30 @@ export function registerListViewLane(tools) {
|
|
|
655
697
|
// lifecycle; this column is a design-time placeholder. The view is
|
|
656
698
|
// live as soon as it is saved. Say so, so the flag is not misread.
|
|
657
699
|
hint: "published 是设计态占位(列表视图无草稿/发布生命周期),false 不代表视图未生效;列/排序/条件/动作/按钮是否落成以 columns/sorts/conditionCount/actionCodes 与 field.list 为准。完整报文加 full:true。NUMERICAL 列的 displayFormat 是平台数值格式枚举(decimal scale2→3、currency→7、percent→6…),不是字段 scale;列的小数位以字段 options.scale 为准(用 field.list 读回)",
|
|
658
|
-
};
|
|
700
|
+
}, columnsDetailed);
|
|
659
701
|
}, {
|
|
660
702
|
compact: (result) => {
|
|
661
703
|
const base = compactReadback(result);
|
|
662
704
|
const detailedSorts = (result.sortsDetailed ?? result.sorts ?? []);
|
|
663
705
|
const detailedConditions = (result.conditionsDetailed ?? result.conditions ?? []);
|
|
706
|
+
const detailedColumns = (Array.isArray(result.columnsDetailed)
|
|
707
|
+
? result.columnsDetailed
|
|
708
|
+
: Array.isArray(result.columns)
|
|
709
|
+
// 极端路径兜底(例如重试后字节跨过 diet 门槛而在 handler 侧被省掉):
|
|
710
|
+
// 直接由内联 columns 对象重建;此时没有 width(columns 投影不带它)。
|
|
711
|
+
? result.columns.map((column) => columnDetail(column, column.sumType))
|
|
712
|
+
: []);
|
|
664
713
|
// 空 detailed 不能留下 compactReadback 的 {count:0,sha256,omitted:true} 占位。
|
|
665
714
|
if (detailedSorts.length === 0)
|
|
666
715
|
delete base.sortsDetailed;
|
|
667
716
|
if (detailedConditions.length === 0)
|
|
668
717
|
delete base.conditionsDetailed;
|
|
718
|
+
if (detailedColumns.length === 0)
|
|
719
|
+
delete base.columnsDetailed;
|
|
669
720
|
const codeOf = (entry) => typeof entry === "string" ? entry : entry && typeof entry === "object" ? String(entry.propertyCode ?? "") : "";
|
|
670
721
|
return {
|
|
671
722
|
...base,
|
|
723
|
+
...(detailedColumns.length > 0 ? { columnsDetailed: detailedColumns } : {}),
|
|
672
724
|
...(detailedSorts.length > 0
|
|
673
725
|
? { sorts: detailedSorts.map(codeOf).filter(Boolean), sortsDetailed: detailedSorts }
|
|
674
726
|
: {}),
|
|
@@ -1514,6 +1566,16 @@ export function registerListViewLane(tools) {
|
|
|
1514
1566
|
message: "平台 delete-on-omit:请求未带 queryDataRangeRestriction(或平台改写)会把既有数据范围限制删掉/改形且返回成功(ModelManagementFacadeImpl.java:2159-2161,242-243)。写已发生,本字段是状态而非失败;用 listview.get --full 复核并到设计器重建数据范围限制。",
|
|
1515
1567
|
};
|
|
1516
1568
|
}
|
|
1569
|
+
// 统一验收等级(0.8.33):旧键(acceptance/conditionRuntimeNote/
|
|
1570
|
+
// viewConditionsAppliedRest/conditionVerification)原样保留,这里只补
|
|
1571
|
+
// 一层统一投影——固定条件只在门户运行面生效,REST data.list --queryCode
|
|
1572
|
+
// 不应用;无固定条件时也没有任何运行面证据,不冒充 verified。
|
|
1573
|
+
readback.verification = conditions.length > 0
|
|
1574
|
+
? verificationConfigOnly("portal", "仅证明视图配置已保存(listview.get 回读 conditions 等价),未证明 REST data.list 应用固定条件——平台无 REST 运行面验证入口,门户点验为准。", {
|
|
1575
|
+
command: `omc call listview.get --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, code })}'`,
|
|
1576
|
+
manual: `门户打开视图 ${code}(模型 ${args.schemaCode}),按固定条件筛选一次并核对返回行`,
|
|
1577
|
+
})
|
|
1578
|
+
: verificationUnverified("rest", "仅证明视图配置已保存并读回;本工具没有调用 data.list 取证运行面(列/排序在 REST 读面是否生效未验证)。", { command: `omc call data.list --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, queryCode: code, size: 1 })}'` });
|
|
1517
1579
|
return { performed: { errcode: performed.errcode }, readback };
|
|
1518
1580
|
},
|
|
1519
1581
|
preflight: assertListViewConfigureShape,
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { JSON_COLUMN_NULL_COALESCE, decodeJsonColumn } from "../../json-column.js";
|
|
2
|
+
import { WireError, wireCall, wireRows } from "../../wire.js";
|
|
3
|
+
import { ENDPOINTS } from "../../endpoints.js";
|
|
4
|
+
/** `data.aggregate` caps: server-total counts are exact; the local-scan fallback shares data.list's row cap. */
|
|
5
|
+
export const AGGREGATE_CAP = 1000;
|
|
6
|
+
export const AGGREGATE_PAGE_SIZE = 200;
|
|
7
|
+
/**
|
|
8
|
+
* 0.6.87 D2:策略标记不靠调用方猜 `complete`。
|
|
9
|
+
* - `server-total`:count 走服务端 totalElements(精确);
|
|
10
|
+
* - `paged-local-scan`:本地扫描真的翻了页(pagesConsumed>1);
|
|
11
|
+
* - `local-scan`:本地扫描一页取齐(无分页发生)。
|
|
12
|
+
* `/sum` 命中时另用 `server-aggregate`(D5)。
|
|
13
|
+
*/
|
|
14
|
+
export function localScanMode(pagesConsumed) {
|
|
15
|
+
return pagesConsumed > 1 ? "paged-local-scan" : "local-scan";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 0.6.87 D5:`/sum` 的 GET_LIST 守卫(平台证据:
|
|
19
|
+
* `DomainServiceImpl.query` 只在 CODING → SourceCodeLauncher、BIZ_SERVICE →
|
|
20
|
+
* integration 时偏离 DB;默认 GET_LIST 仍 `queryFromDb`;`BizObjectRuleUtils
|
|
21
|
+
* .isOperateDbForQuery` 是同一判据;`/sum` 直接 `aggregateBizObjects` →
|
|
22
|
+
* `executeScalar`,**不经过** `DomainServiceImpl.query`,所以只有「可执行
|
|
23
|
+
* GET_LIST 规则仍读 DB」时两边才是同一真相)。
|
|
24
|
+
*
|
|
25
|
+
* 可证明路径:DRAFT 行的 enabled/status/developmentMode 决定 getExecutable 是否
|
|
26
|
+
* 返回规则;DEFAULT 时执行的是 latest PUBLISH 行,故还要读 runtime 面的
|
|
27
|
+
* PUBLISH 行并核对它的 GET_LIST 节点 dataSourceType。任一步读不到/解析不了 →
|
|
28
|
+
* `isDatabase:false`(不能证明 → 本地扫描),fail closed。
|
|
29
|
+
*/
|
|
30
|
+
export const GET_LIST_RULE_CODE = "getlist";
|
|
31
|
+
export function developmentModeName(value) {
|
|
32
|
+
if (typeof value === "number")
|
|
33
|
+
return value === 0 ? "DEFAULT" : value === 1 ? "CODING" : value === 2 ? "DECISION" : String(value);
|
|
34
|
+
return String(value ?? "").toUpperCase();
|
|
35
|
+
}
|
|
36
|
+
export function getListRuleRow(rows) {
|
|
37
|
+
return rows.find((row) => String(row.code ?? "").toLowerCase() === GET_LIST_RULE_CODE);
|
|
38
|
+
}
|
|
39
|
+
export function ruleNodesOf(row) {
|
|
40
|
+
if (row === undefined)
|
|
41
|
+
return undefined;
|
|
42
|
+
const nodes = decodeJsonColumn(row.node, JSON_COLUMN_NULL_COALESCE);
|
|
43
|
+
return Array.isArray(nodes) ? nodes : undefined;
|
|
44
|
+
}
|
|
45
|
+
export async function probeGetListReadsDatabase(session, schemaCode) {
|
|
46
|
+
let wireCalls = 0;
|
|
47
|
+
try {
|
|
48
|
+
// app 面 list 投影 DRAFT 行(getExecutable 的 enabled/status 判据在 DRAFT 上)。
|
|
49
|
+
const drafts = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
|
|
50
|
+
wireCalls += 1;
|
|
51
|
+
const draft = getListRuleRow(drafts);
|
|
52
|
+
if (draft === undefined)
|
|
53
|
+
return { isDatabase: true, wireCalls, reason: "no-get-list-rule" };
|
|
54
|
+
if (draft.enabled === undefined)
|
|
55
|
+
return { isDatabase: false, wireCalls, reason: "get-list-enabled-unknown" };
|
|
56
|
+
if (draft.enabled !== true)
|
|
57
|
+
return { isDatabase: true, wireCalls, reason: "get-list-disabled" };
|
|
58
|
+
if (String(draft.status ?? "").toUpperCase() === "DISABLED")
|
|
59
|
+
return { isDatabase: true, wireCalls, reason: "get-list-disabled" };
|
|
60
|
+
const draftMode = developmentModeName(draft.developmentMode);
|
|
61
|
+
if (draftMode !== "DEFAULT")
|
|
62
|
+
return { isDatabase: false, wireCalls, reason: `get-list-development-mode-${draftMode || "unknown"}` };
|
|
63
|
+
// DEFAULT 时真正执行的是 latest PUBLISH 行,节点以它为准。
|
|
64
|
+
const published = getListRuleRow(wireRows((await wireCall(session, { path: ENDPOINTS.runtimeBusinessRuleListBySchemaCode, query: { schemaCode } })).data));
|
|
65
|
+
wireCalls += 1;
|
|
66
|
+
if (published === undefined)
|
|
67
|
+
return { isDatabase: false, wireCalls, reason: "no-published-get-list" };
|
|
68
|
+
const publishedMode = published.developmentMode === undefined ? "DEFAULT" : developmentModeName(published.developmentMode);
|
|
69
|
+
if (publishedMode !== "DEFAULT")
|
|
70
|
+
return { isDatabase: false, wireCalls, reason: `published-development-mode-${publishedMode || "unknown"}` };
|
|
71
|
+
let nodes = ruleNodesOf(published);
|
|
72
|
+
if (nodes === undefined) {
|
|
73
|
+
const id = typeof published.id === "string" && published.id !== "" ? published.id : undefined;
|
|
74
|
+
if (id === undefined)
|
|
75
|
+
return { isDatabase: false, wireCalls, reason: "get-list-node-unreadable" };
|
|
76
|
+
wireCalls += 1;
|
|
77
|
+
const detail = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
|
|
78
|
+
nodes = ruleNodesOf(detail && typeof detail === "object" ? detail : undefined);
|
|
79
|
+
}
|
|
80
|
+
if (nodes === undefined)
|
|
81
|
+
return { isDatabase: false, wireCalls, reason: "get-list-node-unreadable" };
|
|
82
|
+
const getList = nodes.find((node) => !!node && typeof node === "object" && String(node.nodeType ?? "") === "GET_LIST");
|
|
83
|
+
if (getList === undefined)
|
|
84
|
+
return { isDatabase: false, wireCalls, reason: "get-list-node-missing" };
|
|
85
|
+
const dataSource = getList.dataSourceType;
|
|
86
|
+
const dataSourceName = dataSource === undefined || dataSource === null ? "GET_LIST" : String(dataSource).toUpperCase();
|
|
87
|
+
return { isDatabase: dataSourceName === "GET_LIST", wireCalls, reason: dataSourceName === "GET_LIST" ? "get-list-db" : `get-list-datasource-${dataSourceName}` };
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const detail = error instanceof WireError ? (error.errcode !== undefined ? `errcode ${error.errcode}` : error.kind) : "transport";
|
|
91
|
+
return { isDatabase: false, wireCalls, reason: `get-list-probe-failed:${detail}` };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* D5:调用平台 `/sum` ALL_DATA 并做**运行时键校验**。后端固定回
|
|
96
|
+
* `{COUNT,SUM,MAX,MIN,AVG}`(`BizObjectFacadeImpl.executeAggregateQueries`,
|
|
97
|
+
* decompiled 5667-5674);键缺失/非数 → 视为形状不符,回退本地扫描而不是猜。
|
|
98
|
+
*/
|
|
99
|
+
export async function tryServerSum(session, body, field, metric) {
|
|
100
|
+
try {
|
|
101
|
+
const response = await wireCall(session, {
|
|
102
|
+
path: ENDPOINTS.runtimeQuerySum,
|
|
103
|
+
method: "POST",
|
|
104
|
+
body: { ...body, sumItemList: [{ propertyCode: field, sumDataType: "ALL_DATA" }] },
|
|
105
|
+
});
|
|
106
|
+
const payload = response.data;
|
|
107
|
+
const row = payload && typeof payload === "object" && !Array.isArray(payload) ? payload[field] : undefined;
|
|
108
|
+
if (!row || typeof row !== "object" || Array.isArray(row))
|
|
109
|
+
return { ok: false, reason: "sum-shape-invalid", detail: "missing-field-map" };
|
|
110
|
+
const record = row;
|
|
111
|
+
const count = aggregateNumeric(record.COUNT);
|
|
112
|
+
if (count === null)
|
|
113
|
+
return { ok: false, reason: "sum-shape-invalid", detail: "COUNT" };
|
|
114
|
+
if (count === 0)
|
|
115
|
+
return { ok: true, value: null, nonNullCount: 0 };
|
|
116
|
+
const key = metric === "sum" ? "SUM" : metric === "avg" ? "AVG" : metric === "min" ? "MIN" : "MAX";
|
|
117
|
+
const raw = aggregateNumeric(record[key]);
|
|
118
|
+
if (raw === null)
|
|
119
|
+
return { ok: false, reason: "sum-shape-invalid", detail: key };
|
|
120
|
+
return { ok: true, value: metric === "sum" || metric === "avg" ? aggregateTidy(raw) : raw, nonNullCount: count };
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const detail = error instanceof WireError ? (error.errcode !== undefined ? `errcode ${error.errcode}` : error.kind) : "transport";
|
|
124
|
+
return { ok: false, reason: "sum-failed", detail };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** 数值聚合的字段拒绝面:publishedFields 只列前 N 个(与 data.list 的过滤目录同口径)。 */
|
|
128
|
+
export const AGGREGATE_FIELD_SAMPLE_LIMIT = 20;
|
|
129
|
+
/**
|
|
130
|
+
* 数值列的 wire 值 → number。null/undefined/非数值字符串 → null(null 行**不进**
|
|
131
|
+
* sum/avg/min/max,也不进 min/max 初值比较)。平台数值列通常回 number,兼容回
|
|
132
|
+
* 数字字符串的形状(历史读回见过)。
|
|
133
|
+
*/
|
|
134
|
+
export function aggregateNumeric(value) {
|
|
135
|
+
if (typeof value === "number")
|
|
136
|
+
return Number.isFinite(value) ? value : null;
|
|
137
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
138
|
+
const parsed = Number(value);
|
|
139
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* sum/avg 是**派生值**:12 位有效数字去掉二进制求和噪声(0.1+0.2),不做外推精度、
|
|
145
|
+
* 不改存储值。min/max 是存储值本身,原样返回(tidy 会改掉长整数尾部)。
|
|
146
|
+
*/
|
|
147
|
+
export function aggregateTidy(value) {
|
|
148
|
+
return Number.isFinite(value) ? Number(value.toPrecision(12)) : value;
|
|
149
|
+
}
|
|
150
|
+
export function aggregateValue(metric, sum, nonNullCount, min, max) {
|
|
151
|
+
if (nonNullCount === 0)
|
|
152
|
+
return null;
|
|
153
|
+
if (metric === "sum")
|
|
154
|
+
return aggregateTidy(sum);
|
|
155
|
+
if (metric === "avg")
|
|
156
|
+
return aggregateTidy(sum / nonNullCount);
|
|
157
|
+
return metric === "min" ? min : max;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* `list_child` 的回执是 `PageVO<Map<String,Object>>`(FormRuntimeController
|
|
161
|
+
* .list_child:1921 `new PageVO(data, queryData.getSize())`):总数在
|
|
162
|
+
* `totalElements`(PageVO.java:40-53),`content` 是**扁平行 map**
|
|
163
|
+
* (`toObjectMap()`),不是 query/list 的 `{bizObjectId,data}` 包装。
|
|
164
|
+
*/
|
|
165
|
+
export function childPageOf(payload) {
|
|
166
|
+
const page = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
167
|
+
const rawTotal = page.totalElements;
|
|
168
|
+
const total = typeof rawTotal === "number" && Number.isFinite(rawTotal) ? rawTotal : null;
|
|
169
|
+
const content = Array.isArray(page.content) ? page.content : [];
|
|
170
|
+
return {
|
|
171
|
+
total,
|
|
172
|
+
rows: content.map((row) => (row && typeof row === "object" ? row : {})),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* One property leaf as a level-1 AND group, so it can be appended to ANY base
|
|
177
|
+
* condition (leaf / filters / filterGroup) without re-shaping the existing
|
|
178
|
+
* nesting: level 1 is AND across groups, so `[...base, [[leaf]]]` is exactly
|
|
179
|
+
* `base AND leaf`.
|
|
180
|
+
*/
|
|
181
|
+
export function aggregateLeafGroup(propertyCode, propertyType, queryFilterType, propertyValue) {
|
|
182
|
+
return [[{ propertyCode, propertyValue, queryFilterType, propertyType }]];
|
|
183
|
+
}
|
|
184
|
+
export function withAggregateLeaf(condition, leafGroup) {
|
|
185
|
+
return condition === undefined ? [leafGroup] : [...condition, leafGroup];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Draft口径(继承 data.list r26/r28b 的键名,调用方同一套分支)。
|
|
189
|
+
*
|
|
190
|
+
* - `includeDrafts:false`(含 count+groupBy 的默认)→ 注入 sequenceStatus≠DRAFT(excluded);
|
|
191
|
+
* - count 省略 → 平台默认:无条件时含草稿(included),带条件时平台自己排草稿(excluded);
|
|
192
|
+
* - `includeDrafts:true` → 不注入;无条件时含草稿(included),带条件时平台仍排草稿。
|
|
193
|
+
* - 数值指标(numeric)**不做默认排除**:本地折叠只反映平台返回行,要排除须显式 false。
|
|
194
|
+
*/
|
|
195
|
+
export function aggregateDraftFilter(excludedByRequest, includeDrafts, hasUserCondition, numeric = false) {
|
|
196
|
+
if (excludedByRequest)
|
|
197
|
+
return { draftPolicy: "excluded", hint: numeric ? "includeDrafts:false——已注入 sequenceStatus≠DRAFT;扫描行与桶只计非草稿" : "includeDrafts:false(groupBy 默认)——已注入 sequenceStatus≠DRAFT;total/桶只计非草稿" };
|
|
198
|
+
if (numeric)
|
|
199
|
+
return {
|
|
200
|
+
draftPolicy: "included",
|
|
201
|
+
hint: `数值指标本地折叠不做默认排除:结果反映平台返回行${hasUserCondition ? "(带条件时平台自身排草稿,r26/r28b)" : ""};要排除草稿显式传 includeDrafts:false`,
|
|
202
|
+
};
|
|
203
|
+
if (includeDrafts && hasUserCondition)
|
|
204
|
+
return { draftPolicy: "excluded", hint: "带条件计数时平台排除草稿(r26/r28b);includeDrafts:true 无法强制包含" };
|
|
205
|
+
if (hasUserCondition)
|
|
206
|
+
return { draftPolicy: "excluded", hint: "带条件计数时平台排除草稿(r26/r28b);无条件时 total 含草稿" };
|
|
207
|
+
return { draftPolicy: "included", hint: includeDrafts ? "无条件计数含草稿(平台口径 r28b);要排除用 includeDrafts:false" : "count 省略 includeDrafts=平台默认:无条件 total 含草稿;要排除显式传 false" };
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=aggregate-support.js.map
|