@stalfh233/omc-cli 0.7.0 → 0.8.0
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/coverage/m1-coverage-manifest-v1.json +88 -2
- package/dist/capability-overview.js +16 -4
- package/dist/cli.js +12 -5
- package/dist/contract-resources.js +2 -0
- package/dist/coverage-registry.js +4 -0
- package/dist/coverage.js +16 -2
- package/dist/endpoints.js +65 -0
- package/dist/environment-policy.js +15 -1
- package/dist/field-change.js +9 -2
- package/dist/field-families.js +27 -6
- package/dist/governed-execution.js +18 -12
- package/dist/human-summary.js +8 -0
- package/dist/intent/capabilities/field.js +6 -0
- package/dist/lanes/environment.js +3 -0
- package/dist/lanes/field-contract.js +117 -6
- package/dist/lanes/file-contract.js +69 -0
- package/dist/lanes/file-coverage.js +16 -0
- package/dist/lanes/file.js +257 -0
- package/dist/lanes/lane-ids.js +1 -0
- package/dist/lanes/list-view-contract.js +3 -3
- package/dist/lanes/list-view-shapes.js +56 -0
- package/dist/lanes/list-view.js +40 -5
- package/dist/lanes/meta.js +4 -3
- package/dist/lanes/model.js +8 -4
- package/dist/lanes/org-query-contract.js +62 -0
- package/dist/lanes/org-query-coverage.js +27 -0
- package/dist/lanes/org-query.js +610 -0
- package/dist/lanes/organization.js +44 -11
- package/dist/lanes/runtime-data.js +228 -59
- package/dist/lanes/workflow-contract.js +100 -1
- package/dist/lanes/workflow-coverage.js +13 -0
- package/dist/lanes/workflow.js +599 -13
- package/dist/package.js +3 -1
- package/dist/read-shapes.js +3 -3
- package/dist/recipes/runtime-data.js +8 -6
- package/dist/refusal-guidance.js +1 -1
- package/dist/rule-support.js +15 -17
- package/dist/session.js +16 -1
- package/dist/tool-types.js +15 -1
- package/dist/tools.js +7 -0
- package/dist/version-family-gaps.js +8 -1
- package/dist/version-partition.js +633 -0
- package/dist/wire.js +8 -2
- package/dist/write.js +11 -2
- package/package.json +1 -1
- package/skills/omc-capabilities.md +8 -1
|
@@ -67,12 +67,22 @@ export const FIELD_DATE_DEFAULT_OPTIONS = Object.freeze({
|
|
|
67
67
|
format: "YYYY-MM-DD",
|
|
68
68
|
});
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
* stored value LITERALLY (DateBizField.
|
|
72
|
-
* exactly these strings, else `不支持的format:<value>`):
|
|
73
|
-
* below work; Java's `yyyy-MM-dd` (lowercase y/d) is NOT
|
|
74
|
-
* the first runtime save answer 50000 (2026-09-30 R5
|
|
75
|
-
* default so the default is provably in the enum.
|
|
70
|
+
* The DATE(3) `options.format` enum **on the 8.6 anchor family**. The runtime
|
|
71
|
+
* compares the stored value LITERALLY (8.6.26 `DateBizField.fillClientContent`
|
|
72
|
+
* inlines an if/else over exactly these 19 strings, else `不支持的format:<value>`):
|
|
73
|
+
* the UPPERCASE tokens below work; Java's `yyyy-MM-dd` (lowercase y/d) is NOT
|
|
74
|
+
* one of them and makes the first runtime save answer 50000 (2026-09-30 R5
|
|
75
|
+
* live). Kept beside the default so the default is provably in the enum.
|
|
76
|
+
*
|
|
77
|
+
* EVIDENCE ONLY — this is no longer a gate set. Since the multi-version
|
|
78
|
+
* compatibility decision (2026-11-24) every version is validated against
|
|
79
|
+
* `FIELD_DATE_FORMATS_EVIDENCED` (the 55-item union) and the platform is the
|
|
80
|
+
* final gate. 8.6.26 was decompiled and checked (inline if/else, no
|
|
81
|
+
* `FormatProcessConfig` class in its utility jar); 8.6.34's user-side
|
|
82
|
+
* `cloudpivot-utility` also ships no `FormatProcessConfig` (its engine-side
|
|
83
|
+
* bizobject artifact is not in hand). Later 8.6 patch builds (8.6.39 / 8.6.49)
|
|
84
|
+
* have no local artifact — not assumed either way. See
|
|
85
|
+
* `.scratch/omc-cli-2.1-compat/DATE-86-SURVEY.md`.
|
|
76
86
|
*/
|
|
77
87
|
export const FIELD_DATE_FORMATS = Object.freeze([
|
|
78
88
|
"YYYY", "YYYY-MM", "YYYY/MM",
|
|
@@ -85,6 +95,107 @@ export const FIELD_DATE_FORMATS = Object.freeze([
|
|
|
85
95
|
"YYYY-MM-DD EN-APM HH:mm", "YYYY/MM/DD EN-APM HH:mm",
|
|
86
96
|
"YYYY年MM月DD日", "YYYY年MM月",
|
|
87
97
|
]);
|
|
98
|
+
/**
|
|
99
|
+
* The 36 DATE(3) formats the AI-Platform wide family adds on top of the 8.6
|
|
100
|
+
* anchor set. Evidence: `FormatProcessConfig.FORMAT_RULES`
|
|
101
|
+
* (`isLegalFormat` = `FORMAT_RULES.containsKey(value)`); extracted independently
|
|
102
|
+
* from AI-Platform v2.1.5 and v1.1.23-dsj.8 (8.7.x) — both maps hold exactly
|
|
103
|
+
* the same 55 keys in the same order. The 55 values are a STRICT SUPERSET of
|
|
104
|
+
* the 19 8.6 ones (36 added, 0 removed). Still no milliseconds (`SSS`).
|
|
105
|
+
*/
|
|
106
|
+
const FIELD_DATE_FORMATS_AI_PLATFORM_EXTRA = Object.freeze([
|
|
107
|
+
// 英文日期(无时间)
|
|
108
|
+
"MMM D, YYYY", "MMM. D, YYYY", "MMMM D, YYYY",
|
|
109
|
+
"DD MMMM YYYY", "DD/MM/YYYY", "MM/DD/YYYY",
|
|
110
|
+
// 中文日期 + 时间
|
|
111
|
+
"YYYY年MM月DD日 HH:mm", "YYYY年MM月DD日 HH:mm:ss",
|
|
112
|
+
// 中文 + CN-APM
|
|
113
|
+
"YYYY年MM月DD日 CN-APM", "YYYY年MM月DD日 CN-APM HH:mm",
|
|
114
|
+
// 英文日期 + EN-APM(6 个完整日期形态 × ` EN-APM` / ` EN-APM HH:mm`)
|
|
115
|
+
"MMM D, YYYY EN-APM", "MMM D, YYYY EN-APM HH:mm",
|
|
116
|
+
"MMM. D, YYYY EN-APM", "MMM. D, YYYY EN-APM HH:mm",
|
|
117
|
+
"MMMM D, YYYY EN-APM", "MMMM D, YYYY EN-APM HH:mm",
|
|
118
|
+
"DD MMMM YYYY EN-APM", "DD MMMM YYYY EN-APM HH:mm",
|
|
119
|
+
"DD/MM/YYYY EN-APM", "DD/MM/YYYY EN-APM HH:mm",
|
|
120
|
+
"MM/DD/YYYY EN-APM", "MM/DD/YYYY EN-APM HH:mm",
|
|
121
|
+
// 英文日期 + 24 小时制(同 6 个完整日期形态)
|
|
122
|
+
"MMM D, YYYY HH:mm", "MMM D, YYYY HH:mm:ss",
|
|
123
|
+
"MMM. D, YYYY HH:mm", "MMM. D, YYYY HH:mm:ss",
|
|
124
|
+
"MMMM D, YYYY HH:mm", "MMMM D, YYYY HH:mm:ss",
|
|
125
|
+
"DD MMMM YYYY HH:mm", "DD MMMM YYYY HH:mm:ss",
|
|
126
|
+
"DD/MM/YYYY HH:mm", "DD/MM/YYYY HH:mm:ss",
|
|
127
|
+
"MM/DD/YYYY HH:mm", "MM/DD/YYYY HH:mm:ss",
|
|
128
|
+
// 纯时间
|
|
129
|
+
"HH:mm", "HH:mm:ss",
|
|
130
|
+
]);
|
|
131
|
+
/**
|
|
132
|
+
* DATE(3) `options.format` enum on the AI-Platform wide family — 2.1.5 / 8.7 /
|
|
133
|
+
* 8.8(8.7 与 2.1.5 集合逐字相同)— the 8.6 anchor 19 plus the 36 evidenced
|
|
134
|
+
* additions (55 total). The name is historical (`*_215`); the 8.7 set was
|
|
135
|
+
* extracted separately and is byte-identical to the 2.1.5 one.
|
|
136
|
+
*/
|
|
137
|
+
export const FIELD_DATE_FORMATS_215 = Object.freeze([
|
|
138
|
+
...FIELD_DATE_FORMATS,
|
|
139
|
+
...FIELD_DATE_FORMATS_AI_PLATFORM_EXTRA,
|
|
140
|
+
]);
|
|
141
|
+
/**
|
|
142
|
+
* The single DATE(3) `options.format` gate set for **every** version — the
|
|
143
|
+
* union of all evidenced families (55). 8.6's 19 are a strict subset of the
|
|
144
|
+
* AI-Platform 2.1.5 / 8.7 / 8.8 set, so the union is that 55-item list.
|
|
145
|
+
*
|
|
146
|
+
* Deliberate multi-version compatibility trade-off (2026-11-24): OMC does not
|
|
147
|
+
* adjudicate the platform version for this option. A known 8.6 server that
|
|
148
|
+
* receives a 55-only value reports 50000 on the first runtime save and OMC
|
|
149
|
+
* surfaces that error as-is (平台是最终门). Only values no evidenced platform
|
|
150
|
+
* accepts are refused up front.
|
|
151
|
+
*/
|
|
152
|
+
export const FIELD_DATE_FORMATS_EVIDENCED = FIELD_DATE_FORMATS_215;
|
|
153
|
+
/**
|
|
154
|
+
* Informational classification of a detected version against the two evidenced
|
|
155
|
+
* families. **NOT a gate** — no code path refuses a DATE format based on this;
|
|
156
|
+
* see `FIELD_DATE_FORMATS_EVIDENCED` for the accepted set.
|
|
157
|
+
*
|
|
158
|
+
* Evidence per family (all 55-item sets extracted from the jar constant pool,
|
|
159
|
+
* `FormatProcessConfig.FORMAT_RULES`, and byte-identical):
|
|
160
|
+
* * 2.1.x — AI-Platform v2.1.5 (customer-facing 8.8)
|
|
161
|
+
* * 8.7.x — AI-Platform v1.1.23-dsj.8: `DateBizField.fillClientContent`
|
|
162
|
+
* calls `FormatProcessConfig.isLegalFormat(...)` instead of the 8.6
|
|
163
|
+
* inline if/else, and that map holds the same 55 keys.
|
|
164
|
+
* * 8.8 — the 2.1.x line under its 8.x spelling (same mapping already used
|
|
165
|
+
* by `perm`/`workflow` lanes).
|
|
166
|
+
* * 8.6.x — the 19-item anchor (8.6.26 inline if/else; 8.6.34 has no
|
|
167
|
+
* FormatProcessConfig class).
|
|
168
|
+
*
|
|
169
|
+
* Everything else (2.0.x, 2.2.x, 2.10.x, 3.x, 8.9+, 9.x, unknown, unparsable)
|
|
170
|
+
* is deliberately left `undefined` — we have no evidence to classify it, and it
|
|
171
|
+
* must not be mistaken for an evidenced family.
|
|
172
|
+
*/
|
|
173
|
+
export function fieldDateFormatFamily(version) {
|
|
174
|
+
if (typeof version !== "string")
|
|
175
|
+
return undefined;
|
|
176
|
+
const match = /^\s*(\d+)\.(\d+)/u.exec(version);
|
|
177
|
+
if (!match)
|
|
178
|
+
return undefined;
|
|
179
|
+
const major = Number(match[1]);
|
|
180
|
+
const minor = Number(match[2]);
|
|
181
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor))
|
|
182
|
+
return undefined;
|
|
183
|
+
if (major === 8 && minor === 6)
|
|
184
|
+
return "anchor";
|
|
185
|
+
if (major === 2 && minor === 1)
|
|
186
|
+
return "ai-platform";
|
|
187
|
+
if (major === 8 && (minor === 7 || minor === 8))
|
|
188
|
+
return "ai-platform";
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated Version selection was removed (multi-version compatibility):
|
|
193
|
+
* always returns the evidenced 55-item union, same as the DATE gate. The
|
|
194
|
+
* `version` argument is ignored and kept only for source compatibility.
|
|
195
|
+
*/
|
|
196
|
+
export function fieldDateFormatsFor(_version) {
|
|
197
|
+
return FIELD_DATE_FORMATS_EVIDENCED;
|
|
198
|
+
}
|
|
88
199
|
/** FORMULA(100) options wire (8.6.26 FormulaPropertyOptions + admin field serializer). */
|
|
89
200
|
export const FIELD_FORMULA_WIRE = Object.freeze({
|
|
90
201
|
outerOptions: '{"formulaConfig":"<JSON string>","persistent":true[, "format":""|"percentile" — readback-only mirror, fwb §100]}',
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { assertDescriptionCarries, assertLaneContract, behaviorBinding, CONTRACT_FAMILY, CONTRACT_REFERENCE_VERSION } from "./contract-support.js";
|
|
2
|
+
import { LANES } from "./lane-ids.js";
|
|
3
|
+
/**
|
|
4
|
+
* File-transfer lane wire paths.
|
|
5
|
+
*
|
|
6
|
+
* 待收编:`src/endpoints.ts` 正被并行任务修改,本 lane 暂在这里持有个位数
|
|
7
|
+
* 路径常量;收编时原样搬进 ENDPOINTS(值已按网关前缀 `/api/api` 实测形状
|
|
8
|
+
* 写死,搬动只改引用、不改字符串)。
|
|
9
|
+
*/
|
|
10
|
+
export const FILE_ENDPOINTS = Object.freeze({
|
|
11
|
+
/** QueryRuntimeController.java:2415-2428(8.6.26)/ 2939-2946(2.1.5):multipart field `file` → 纯字符串 refId。 */
|
|
12
|
+
upload: "/api/api/runtime/query/upload_file",
|
|
13
|
+
/** FileServerController.java:78-113(8.6.26)/ 67-90(2.1.5):GET ?refId= → 附件二进制流。 */
|
|
14
|
+
attachmentDownload: "/api/api/fileServer/attachment",
|
|
15
|
+
/** QueryRuntimeController.java:2868-2890(8.6.26)/ 3287-3306(2.1.5):POST {fileName:refId} → 原始存储对象二进制流。 */
|
|
16
|
+
storedDownload: "/api/api/runtime/query/download_import_error_info",
|
|
17
|
+
});
|
|
18
|
+
export const FILE_LANE_CONTRACT = Object.freeze({
|
|
19
|
+
lane: LANES.file,
|
|
20
|
+
family: CONTRACT_FAMILY,
|
|
21
|
+
referenceVersion: CONTRACT_REFERENCE_VERSION,
|
|
22
|
+
// 待收编 endpoints.ts:见 FILE_ENDPOINTS 注释。
|
|
23
|
+
endpoints: Object.freeze({}),
|
|
24
|
+
wire: Object.freeze({
|
|
25
|
+
upload: "POST /api/api/runtime/query/upload_file — multipart/form-data field `file`;回包是**纯字符串 refId**(不是 {errcode,data} 信封)。QueryRuntimeController.java:2415-2428(8.6.26)/ 2939-2946(2.1.5)。",
|
|
26
|
+
downloadAttachment: "GET /api/api/fileServer/attachment?refId=<refId> — 附件二进制流(Content-Disposition 带原始文件名);失败回 200 + {errcode,errmsg} JSON(OSS_DOWNLOAD_PERMISSION_ERR 等)。FileServerController.java:78-113(8.6.26)/ 67-90(2.1.5)。",
|
|
27
|
+
downloadStored: "POST /api/api/runtime/query/download_import_error_info body {fileName:<refId>} — 以存储对象键直取二进制流(upload_file 的 refId 就是存储键);失败被控制器吞掉,回 200 + 空 body。QueryRuntimeController.java:2868-2890(8.6.26)/ 3287-3306(2.1.5)。",
|
|
28
|
+
fileTypeGate: "上传端 checkFileType 只看文件名:必须含扩展名(最后一个 . 之后非空)、不得含 `..`、扩展名须在平台设置 allow_file_types 白名单;源码无固定大小上限(由部署的 multipart/nginx 限制)。OSSController.checkFileType(8.6.26 OSSController.java:306-330)。",
|
|
29
|
+
oneShotRefId: "refId 可能是**一次性**:FileOperateHelper2.downloadFile(filePath,fileName,delete=true) 在取文件时 refIdToFilenameCache.remove(refId)(8.6.26 FileOperateHelper2.java:43-57;2.1.5 同函数 65-76),业务集成 check/import 等消费型链路走的就是 delete=true——同一 refId 不要假定可重复消费。",
|
|
30
|
+
}),
|
|
31
|
+
wireBindings: Object.freeze({
|
|
32
|
+
upload: Object.freeze([behaviorBinding("test/file-transfer.test.ts#file.upload: multipart field `file` → plain-string refId", assertFileContract)]),
|
|
33
|
+
downloadAttachment: Object.freeze([behaviorBinding("test/file-transfer.test.ts#file.download: attachment source streams bytes and surfaces envelope refusals", assertFileContract)]),
|
|
34
|
+
downloadStored: Object.freeze([behaviorBinding("test/file-transfer.test.ts#file.download: stored source writes the bytes and reports path/size/sha256", assertFileContract)]),
|
|
35
|
+
fileTypeGate: Object.freeze([behaviorBinding("test/file-transfer.test.ts#file.upload: local preflight rejects a filename the platform checkFileType would reject", assertFileContract)]),
|
|
36
|
+
oneShotRefId: Object.freeze([behaviorBinding("test/file-transfer.test.ts#file.download: a consumed/unknown refId is answered as a definitive refusal", assertFileContract)]),
|
|
37
|
+
}),
|
|
38
|
+
evidence: Object.freeze([
|
|
39
|
+
"cp-sources/backend/decompiled-full/launcher-8.6.26/.../QueryRuntimeController.java:2415-2428,2868-2890",
|
|
40
|
+
"cp-sources/backend/decompiled-full/launcher-8.6.26/.../FileServerController.java:78-113",
|
|
41
|
+
"cp-sources/backend/decompiled-full/launcher-8.6.26/.../FileOperateHelper2.java:35-57",
|
|
42
|
+
"cp-sources/backend/decompiled-full/launcher-2.1.5/.../QueryRuntimeController.java:2939-2946,3287-3306",
|
|
43
|
+
"cp-sources/backend/decompiled-full/launcher-2.1.5/.../FileServerController.java:67-90",
|
|
44
|
+
"packages/omc-cli/src/lanes/file.ts",
|
|
45
|
+
"packages/omc-cli/test/file-transfer.test.ts",
|
|
46
|
+
]),
|
|
47
|
+
tools: Object.freeze({
|
|
48
|
+
"file.upload": Object.freeze({
|
|
49
|
+
scope: "file upload (multipart → refId)",
|
|
50
|
+
description: "把本地文件上传到平台对象存储,返回纯字符串 refId。multipart 字段 `file`;服务器 checkFileType 只看文件名(必须含扩展名、不得含 `..`、扩展名须在平台 allow_file_types 白名单,白名单是平台设置、本地不可预知),源码无固定大小上限(由部署 multipart/nginx 决定)。上传会产生一个真实存储对象且平台没有删除端点。refId 可能一次性:平台消费型下载(业务集成 check/import 等 delete=true)会移除 refId→文件名缓存,之后不可复用——重试请重新上传。下载用 file.download;本工具返回的临时 refId 用 source:\"stored\"。",
|
|
51
|
+
}),
|
|
52
|
+
"file.download": Object.freeze({
|
|
53
|
+
scope: "file download (refId → local path)",
|
|
54
|
+
description: "按 refId 下载文件到本地路径(默认当前目录),返回 path/size/sha256;二进制不进 stdout。source:attachment(默认)=表单附件 refId,走 attachment 权限,失败回 200+{errcode};source:stored=上传临时对象(file.upload 的 refId),走 download_import_error_info 的存储键通道,失败回 200+空 body。refId 可能一次性(平台消费型接口 delete=true 会移除 refId→文件名缓存);取不到字节按 file-ref-unavailable 明确拒绝并提示重新上传。整文件读入内存,大文件请在平台前台下载。目标已存在默认拒绝(overwrite:true 覆盖),落盘 0600。",
|
|
55
|
+
}),
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
export function assertFileContract() {
|
|
59
|
+
assertLaneContract(FILE_LANE_CONTRACT);
|
|
60
|
+
assertDescriptionCarries(FILE_LANE_CONTRACT, "file.upload", ["multipart", "allow_file_types", "一次性", "refId"]);
|
|
61
|
+
assertDescriptionCarries(FILE_LANE_CONTRACT, "file.download", ["sha256", "source:stored", "一次性", "overwrite"]);
|
|
62
|
+
if (!String(FILE_LANE_CONTRACT.wire.upload).includes("纯字符串"))
|
|
63
|
+
throw new Error("file contract must pin the plain-string refId response");
|
|
64
|
+
if (!String(FILE_LANE_CONTRACT.wire.downloadStored).includes("空 body"))
|
|
65
|
+
throw new Error("file contract must pin the swallowed-error signature of download_import_error_info");
|
|
66
|
+
if (!String(FILE_LANE_CONTRACT.wire.oneShotRefId).includes("FileOperateHelper2.java:43-57"))
|
|
67
|
+
throw new Error("file contract must pin the one-shot refId evidence");
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=file-contract.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { claim, declareLaneCoverage } from "./coverage-declaration.js";
|
|
2
|
+
import { FILE_LANE_CONTRACT } from "./file-contract.js";
|
|
3
|
+
const T = FILE_LANE_CONTRACT.tools;
|
|
4
|
+
export const FILE_COVERAGE = declareLaneCoverage(FILE_LANE_CONTRACT.lane, [
|
|
5
|
+
{
|
|
6
|
+
capability: "Runtime file transfer (multipart upload refId ↔ local path download)",
|
|
7
|
+
evidence: [
|
|
8
|
+
"cp-sources/backend/decompiled-full/launcher-8.6.26/.../QueryRuntimeController.java:2415-2428,2868-2890",
|
|
9
|
+
"cp-sources/backend/decompiled-full/launcher-8.6.26/.../FileServerController.java:78-113",
|
|
10
|
+
"packages/omc-cli/src/lanes/file.ts",
|
|
11
|
+
"packages/omc-cli/test/file-transfer.test.ts",
|
|
12
|
+
],
|
|
13
|
+
tools: [claim("file.upload", T["file.upload"].scope), claim("file.download", T["file.download"].scope)],
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
//# sourceMappingURL=file-coverage.js.map
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { capabilityArg, environmentArg } from "../args.js";
|
|
7
|
+
import { governedRead } from "../read.js";
|
|
8
|
+
import { writeTool } from "../write.js";
|
|
9
|
+
import { defineTool, ToolRefusalError } from "../tool-types.js";
|
|
10
|
+
import { wireUploadFile, WireError } from "../wire.js";
|
|
11
|
+
import { FILE_ENDPOINTS, FILE_LANE_CONTRACT } from "./file-contract.js";
|
|
12
|
+
const LANE = FILE_LANE_CONTRACT.lane;
|
|
13
|
+
const TOOLS = FILE_LANE_CONTRACT.tools;
|
|
14
|
+
/**
|
|
15
|
+
* One-shot teaching shared by both tools: the refId→filename cache entry is
|
|
16
|
+
* removed by a consuming download (`delete=true`), so a refId that worked for
|
|
17
|
+
* one server-side flow may be dead on the next call.
|
|
18
|
+
*/
|
|
19
|
+
const ONE_SHOT_NOTE = "refId 可能是一次性的:平台消费型下载(业务集成 check/import 等 delete=true)取完就删除 refId→文件名缓存,之后不可复用——重试请重新上传,不要假定同一 refId 能反复消费。";
|
|
20
|
+
const UPLOAD_DRY_RUN_REFUSAL = {
|
|
21
|
+
status: "refused",
|
|
22
|
+
blocker: "file-upload-dry-run-unsupported",
|
|
23
|
+
message: "file.upload 不支持 --dry-run:上传本身是取回 refId 的唯一途径,不上传就不存在可用的 refId(且上传会在平台对象存储留下一个真实对象),预览无法诚实给出 wouldChange。参数预检请用 --preflight;确认执行时去掉 --dry-run。",
|
|
24
|
+
};
|
|
25
|
+
function expandHome(value) {
|
|
26
|
+
if (value === "~")
|
|
27
|
+
return homedir();
|
|
28
|
+
if (value.startsWith("~/") || value.startsWith("~\\"))
|
|
29
|
+
return join(homedir(), value.slice(2));
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
function absolute(value) {
|
|
33
|
+
const expanded = expandHome(value);
|
|
34
|
+
return isAbsolute(expanded) ? resolve(expanded) : resolve(process.cwd(), expanded);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The platform's checkFileType inspects only the filename: it must contain a
|
|
38
|
+
* non-empty suffix after the last dot, must not contain `..`, and the suffix
|
|
39
|
+
* must be on the deployment's allow_file_types list (a platform setting we
|
|
40
|
+
* cannot read offline). Preflight the two locally-decidable rules.
|
|
41
|
+
*/
|
|
42
|
+
function uploadPreflight(args) {
|
|
43
|
+
const source = absolute(args.path);
|
|
44
|
+
if (!existsSync(source))
|
|
45
|
+
throw new ToolRefusalError({
|
|
46
|
+
status: "refused",
|
|
47
|
+
blocker: "file-upload-source-missing",
|
|
48
|
+
path: source,
|
|
49
|
+
message: `本地文件不存在:${source}。file.upload 只上传本机可读的普通文件(路径不存在即拒绝,零上传)。`,
|
|
50
|
+
});
|
|
51
|
+
const stats = statSync(source);
|
|
52
|
+
if (!stats.isFile())
|
|
53
|
+
throw new ToolRefusalError({
|
|
54
|
+
status: "refused",
|
|
55
|
+
blocker: "file-upload-source-not-file",
|
|
56
|
+
path: source,
|
|
57
|
+
message: `${source} 不是普通文件(目录/设备/管道均不支持)。请指向具体文件。`,
|
|
58
|
+
});
|
|
59
|
+
const remoteName = args.name ?? basename(source);
|
|
60
|
+
if (/[\\/]/.test(remoteName) || remoteName.includes(".."))
|
|
61
|
+
throw new ToolRefusalError({
|
|
62
|
+
status: "refused",
|
|
63
|
+
blocker: "file-upload-name-invalid",
|
|
64
|
+
name: remoteName,
|
|
65
|
+
message: `上传文件名 ${JSON.stringify(remoteName)} 含路径分隔符或 ".."——平台 checkFileType 会拒(文件名只能是裸名);用 name 指定一个不含目录的名字。`,
|
|
66
|
+
});
|
|
67
|
+
const lastDot = remoteName.lastIndexOf(".");
|
|
68
|
+
if (lastDot < 0 || lastDot === remoteName.length - 1)
|
|
69
|
+
throw new ToolRefusalError({
|
|
70
|
+
status: "refused",
|
|
71
|
+
blocker: "file-upload-name-invalid",
|
|
72
|
+
name: remoteName,
|
|
73
|
+
message: `上传文件名 ${JSON.stringify(remoteName)} 没有扩展名——平台 checkFileType 取最后一个 "." 之后的 suffix,空 suffix 直接拒(FILE_TYPE_ILLEGAL)。用 name 补一个真实扩展名。`,
|
|
74
|
+
hint: "扩展名还必须在平台设置的 allow_file_types 白名单里;白名单是环境配置,本地不可预知,被平台拒时按平台返回的类型清单调整。",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Decode the two download channels into bytes.
|
|
79
|
+
*
|
|
80
|
+
* - attachment: 200 + {errcode,errmsg} is how the platform refuses (the
|
|
81
|
+
* attachment must resolve through AttachmentModel/AttachmentCache).
|
|
82
|
+
* - stored: the controller swallows every failure and answers 200 with an
|
|
83
|
+
* EMPTY body (QueryRuntimeController.java:2868-2890), so empty == refusal.
|
|
84
|
+
* Its body is a raw storage object, so it is never envelope-sniffed — a
|
|
85
|
+
* downloaded .json must round-trip byte-for-byte.
|
|
86
|
+
*/
|
|
87
|
+
async function wireFileBytes(session, source, refId) {
|
|
88
|
+
const path = source === "attachment" ? FILE_ENDPOINTS.attachmentDownload : FILE_ENDPOINTS.storedDownload;
|
|
89
|
+
const response = source === "attachment"
|
|
90
|
+
? await session.request({ path, method: "GET", query: { refId }, responseType: "buffer" })
|
|
91
|
+
: await session.request({ path, method: "POST", body: { fileName: refId }, responseType: "buffer" });
|
|
92
|
+
if (response.status < 200 || response.status >= 300)
|
|
93
|
+
throw new WireError("http-status", `HTTP ${response.status} for ${path} (${source} download, refId=${refId})`, undefined, { httpStatus: response.status });
|
|
94
|
+
const body = Buffer.isBuffer(response.body)
|
|
95
|
+
? response.body
|
|
96
|
+
: typeof response.body === "string"
|
|
97
|
+
? Buffer.from(response.body, "utf8")
|
|
98
|
+
: undefined;
|
|
99
|
+
if (body === undefined)
|
|
100
|
+
throw new WireError("malformed-envelope", `${path} answered no bytes for refId=${refId} (${source} download)`);
|
|
101
|
+
if (body.length === 0)
|
|
102
|
+
throw new ToolRefusalError({
|
|
103
|
+
status: "refused",
|
|
104
|
+
blocker: "file-ref-unavailable",
|
|
105
|
+
refId,
|
|
106
|
+
source,
|
|
107
|
+
message: `refId ${JSON.stringify(refId)} 没有取到任何字节:它可能已被消费、已过期,或根本不属于本租户。${ONE_SHOT_NOTE} 来源通道也要对:file.upload 的临时 refId 用 source:"stored",表单附件 refId 用 source:"attachment"。`,
|
|
108
|
+
});
|
|
109
|
+
if (source === "attachment" && body[0] === 0x7b) {
|
|
110
|
+
let parsed;
|
|
111
|
+
try {
|
|
112
|
+
parsed = JSON.parse(body.toString("utf8"));
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
parsed = undefined;
|
|
116
|
+
}
|
|
117
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
118
|
+
const envelope = parsed;
|
|
119
|
+
if (typeof envelope.errcode === "number") {
|
|
120
|
+
if (envelope.errcode !== 0)
|
|
121
|
+
throw new ToolRefusalError({
|
|
122
|
+
status: "refused",
|
|
123
|
+
blocker: "file-ref-unavailable",
|
|
124
|
+
refId,
|
|
125
|
+
source,
|
|
126
|
+
errcode: envelope.errcode,
|
|
127
|
+
message: `平台拒绝下载 refId ${JSON.stringify(refId)}(errcode ${envelope.errcode}${typeof envelope.errmsg === "string" ? `:${envelope.errmsg}` : ""})。attachment 通道要求 refId 能在附件表/附件缓存解析;若是 file.upload 返回的临时 refId,改用 source:"stored"。${ONE_SHOT_NOTE}`,
|
|
128
|
+
hint: "若这是普通附件却用错了 refId(多附件字段里混入了别的对象 id),先用 data.load 读该字段的 refId 列表。",
|
|
129
|
+
});
|
|
130
|
+
throw new WireError("malformed-envelope", `${path} answered an errcode-0 JSON envelope instead of an attachment stream`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return body;
|
|
135
|
+
}
|
|
136
|
+
function safeFileName(value) {
|
|
137
|
+
const cleaned = basename(value).replaceAll(/[<>:"/\\|?*\u0000-\u001f]/g, "_").replaceAll(/\s+/g, " ").trim();
|
|
138
|
+
const withoutLeadingDots = cleaned.replace(/^\.+/, "");
|
|
139
|
+
return withoutLeadingDots.length > 0 ? withoutLeadingDots : "download.bin";
|
|
140
|
+
}
|
|
141
|
+
/** `path` may be a file path or an existing directory (trailing separator counts). */
|
|
142
|
+
function downloadTarget(args) {
|
|
143
|
+
if (args.fileName !== undefined && args.fileName !== basename(args.fileName))
|
|
144
|
+
throw new ToolRefusalError({
|
|
145
|
+
status: "refused",
|
|
146
|
+
blocker: "file-download-name-invalid",
|
|
147
|
+
fileName: args.fileName,
|
|
148
|
+
message: `fileName ${JSON.stringify(args.fileName)} 只能是裸文件名(不能带目录);目录用 path 指定。`,
|
|
149
|
+
});
|
|
150
|
+
const suggested = safeFileName(args.fileName ?? basename(args.refId));
|
|
151
|
+
if (args.path === undefined)
|
|
152
|
+
return join(process.cwd(), suggested);
|
|
153
|
+
const raw = absolute(args.path);
|
|
154
|
+
const looksLikeDir = existsSync(raw) ? statSync(raw).isDirectory() : /[\\/]$/.test(args.path);
|
|
155
|
+
return looksLikeDir ? join(raw, suggested) : raw;
|
|
156
|
+
}
|
|
157
|
+
export function registerFileLane(tools) {
|
|
158
|
+
writeTool({
|
|
159
|
+
tools,
|
|
160
|
+
name: "file.upload",
|
|
161
|
+
search: { intents: ["上传文件", "传文件到平台", "拿文件引用", "附件上传", "multipart 上传"] },
|
|
162
|
+
lane: LANE,
|
|
163
|
+
scope: TOOLS["file.upload"].scope,
|
|
164
|
+
description: TOOLS["file.upload"].description,
|
|
165
|
+
inputSchema: {
|
|
166
|
+
path: z.string().min(1).describe("本地文件路径(绝对路径或相对当前目录;~ 会展开)"),
|
|
167
|
+
name: z.string().min(1).optional().describe("上传后的文件名(默认取本地 basename);必须保留真实扩展名,不能带目录或 `..`"),
|
|
168
|
+
},
|
|
169
|
+
preflight: (args) => uploadPreflight(args),
|
|
170
|
+
// The upload IS the operation: there is no honest zero-write preview that
|
|
171
|
+
// yields a usable refId. Refuse instead of faking a green plan.
|
|
172
|
+
dryRunPayload: async () => {
|
|
173
|
+
throw new ToolRefusalError(UPLOAD_DRY_RUN_REFUSAL);
|
|
174
|
+
},
|
|
175
|
+
execute: async (session, args) => {
|
|
176
|
+
const source = absolute(args.path);
|
|
177
|
+
const remoteName = args.name ?? basename(source);
|
|
178
|
+
const bytes = readFileSync(source);
|
|
179
|
+
const refId = await wireUploadFile(session, FILE_ENDPOINTS.upload, remoteName, bytes, "application/octet-stream");
|
|
180
|
+
return {
|
|
181
|
+
performed: { uploaded: true, filename: remoteName, bytes: bytes.length },
|
|
182
|
+
readback: {
|
|
183
|
+
refId,
|
|
184
|
+
refIdKind: "plain-string",
|
|
185
|
+
oneShot: true,
|
|
186
|
+
// Honest verification stamp: upload_file is the only refId metadata
|
|
187
|
+
// face — there is no read-by-refId endpoint, so the byte count is
|
|
188
|
+
// local truth (stat/body), not a server readback.
|
|
189
|
+
verified: false,
|
|
190
|
+
verification: "upload_file 只回纯字符串 refId(无按 refId 读元数据的端点);这里核对的是本地上传字节数,不是服务端回读。",
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
tools.push(defineTool({
|
|
196
|
+
name: "file.download",
|
|
197
|
+
search: { intents: ["下载文件", "按 refId 下载", "把平台文件存到本地", "附件下载", "导出附件"] },
|
|
198
|
+
layer: "low",
|
|
199
|
+
kind: "read",
|
|
200
|
+
lane: LANE,
|
|
201
|
+
scope: TOOLS["file.download"].scope,
|
|
202
|
+
description: TOOLS["file.download"].description,
|
|
203
|
+
inputSchema: {
|
|
204
|
+
environment: environmentArg,
|
|
205
|
+
capability: capabilityArg,
|
|
206
|
+
refId: z.string().min(1).describe("平台文件引用(附件 refId,或 file.upload 返回的临时 refId)"),
|
|
207
|
+
source: z.enum(["attachment", "stored"]).default("attachment").describe("attachment=表单附件通道(默认,走附件权限);stored=upload_file 临时对象的存储键通道(失败回空 body)"),
|
|
208
|
+
path: z.string().min(1).optional().describe("本地目标文件路径,或已存在/以分隔符结尾的目录(默认当前目录)"),
|
|
209
|
+
fileName: z.string().min(1).optional().describe("落盘文件名(仅裸名;默认取 refId 的 basename)"),
|
|
210
|
+
overwrite: z.boolean().default(false).describe("目标已存在时是否覆盖(默认拒绝,零写入)"),
|
|
211
|
+
},
|
|
212
|
+
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
213
|
+
const target = downloadTarget(args);
|
|
214
|
+
const existed = existsSync(target);
|
|
215
|
+
if (existsSync(target) && statSync(target).isDirectory())
|
|
216
|
+
throw new ToolRefusalError({
|
|
217
|
+
status: "refused",
|
|
218
|
+
blocker: "file-download-target-exists",
|
|
219
|
+
path: target,
|
|
220
|
+
message: `${target} 是目录——path 指向目录时会被当作目录拼接 fileName,但这里解析出的最终目标仍是目录。请给出明确文件名。`,
|
|
221
|
+
});
|
|
222
|
+
if (existsSync(target) && args.overwrite !== true)
|
|
223
|
+
throw new ToolRefusalError({
|
|
224
|
+
status: "refused",
|
|
225
|
+
blocker: "file-download-target-exists",
|
|
226
|
+
path: target,
|
|
227
|
+
existingBytes: statSync(target).size,
|
|
228
|
+
message: `目标文件已存在:${target}(${statSync(target).size}B)。默认不覆盖(避免把用户文件当下载缓存);确认覆盖传 overwrite:true,或换 path/fileName。`,
|
|
229
|
+
});
|
|
230
|
+
const bytes = await wireFileBytes(session, args.source, args.refId);
|
|
231
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
232
|
+
writeFileSync(target, bytes, { mode: 0o600 });
|
|
233
|
+
// writeFileSync's mode only applies on creation; an overwrite keeps the
|
|
234
|
+
// old bits. Make 0600 true where the platform supports it (Windows
|
|
235
|
+
// exposes only the write bit; a restricted FS must not fail the download).
|
|
236
|
+
try {
|
|
237
|
+
chmodSync(target, 0o600);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// best-effort on file systems without POSIX modes
|
|
241
|
+
}
|
|
242
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
243
|
+
return {
|
|
244
|
+
refId: args.refId,
|
|
245
|
+
source: args.source,
|
|
246
|
+
path: target,
|
|
247
|
+
fileName: basename(target),
|
|
248
|
+
size: bytes.length,
|
|
249
|
+
sha256,
|
|
250
|
+
overwritten: existed && args.overwrite === true,
|
|
251
|
+
note: "二进制已落盘(0600),未内联到 stdout;sha256 是落盘字节的摘要,可直接用于完整性校验。",
|
|
252
|
+
...(args.source === "stored" ? { channelNote: "stored 通道不校验附件权限,只证明该存储键可取;refId 失效时平台回空 body(已按 file-ref-unavailable 拒绝)。" } : {}),
|
|
253
|
+
};
|
|
254
|
+
}),
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=file.js.map
|
package/dist/lanes/lane-ids.js
CHANGED
|
@@ -12,7 +12,7 @@ export const LIST_VIEW_WIRE = Object.freeze({
|
|
|
12
12
|
configureDefault: "code omitted means the default view (code=schemaCode)",
|
|
13
13
|
configureColumns: "query/get then query/update: for each fieldCodes entry, append a missing column as visible, or repair an existing column's name/propertyType/displayFormat/visible in place (never skip an already-present column), then query/get readback; propertyType comes from published field metadata; NUMERICAL displayFormat is derived from the field's 0-based `options.scale` (0=integer,1=1dp,2=2dp,3=3dp…8=8dp) through the platform parseNumber table ({0:1,1:2,2:3,3:11,4:12,23:…, percent 0..:4/5/6/13/14/27..30, currency ¥ 2dp..:7/15/16/31..34} — verified live: scale 2 → displayFormat 3 = 2 decimals) and DATE displayFormat from options.format (1=yyyy-MM-dd,2=datetime,3=minute,4=yyyy-MM); the readback columns array carries {propertyCode,propertyType,displayFormat,visible,sumType} and added/updated name the fieldCodes touched",
|
|
14
14
|
configureSorts: "sorts -> querySorts [{propertyCode,propertyType,direction,sortKey,clientType}]; direction SortDirectionType numeric ASC(1)/DESC(2); omitted leaves the existing sorts untouched, provided replaces them",
|
|
15
|
-
configureConditions: "conditions -> queryConditions [{propertyCode,propertyType,displayType,filterType,defaultValue,options,startValue,endValue,shortcutFilter,choiceType,dateType,accurateSearch,showNull,includeSubData,buildTreeBy,visible}]; minimum --param shape: {\"conditions\":[{\"propertyCode\":\"<code>\",\"filterType\":\"Eq\",\"defaultValue\":<value>}]}; filterType is the comparison OPERATOR (QueryFilterType STRING enum: Eq/NotEq/Gt/Lt/Gte/Lte/Like/NotLike/IsNull/IsNotNull/In/NotIn/Between/NotBetween/Of/NotOf/…; omitted → the platform default for the propertyType; aliases operator/op and legacy options.op); displayType INPUT(0)/RADIO(1)/CHECKBOX(2)/SELECT(3)/RANGE(4); choiceType SELECT(1)/POPUP(2)/TREE_LEFT(3); options is a JSON string (decoded on readback); conditionReadback is equivalent only for field-by-field equality, otherwise coerced with from/to details; viewConditionsAppliedRest:false records that REST data.list --queryCode does not apply fixed conditions",
|
|
15
|
+
configureConditions: "conditions -> queryConditions [{propertyCode,propertyType,displayType,filterType,defaultValue,options,startValue,endValue,shortcutFilter,choiceType,dateType,accurateSearch,showNull,includeSubData,buildTreeBy,visible,treeLimitScopeType,treeLimitConditionGroup,treeDefaultConditionGroup}]; minimum --param shape: {\"conditions\":[{\"propertyCode\":\"<code>\",\"filterType\":\"Eq\",\"defaultValue\":<value>}]}; filterType is the comparison OPERATOR (QueryFilterType STRING enum: Eq/NotEq/Gt/Lt/Gte/Lte/Like/NotLike/IsNull/IsNotNull/In/NotIn/Between/NotBetween/Of/NotOf/…; omitted → the platform default for the propertyType; aliases operator/op and legacy options.op); displayType INPUT(0)/RADIO(1)/CHECKBOX(2)/SELECT(3)/RANGE(4); choiceType SELECT(1)/POPUP(2)/TREE_LEFT(3); options is a JSON string (decoded on readback); the 2.1.5 tree-view triple treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup is read as List<List<BizQueryDataRangeCondition>> [[{propertyCode,propertyType,operatorType,valueType,value,dynamicValue}]] and passed through verbatim: a baseline key with a DIFFERENT value refuses with listview-tree-conditions-changed (nextAction allowTreeConditionChange:true) and a baseline key omitted from the submitted row refuses with listview-tree-conditions-would-be-lost; value equality canonicalises JSON text vs object, object key order, and numeric propertyType/operatorType (\"1\"==1) but keeps value/dynamicValue string-strict; readback compares all three keys whenever either side carries one and reports the drift as a coercion; conditionReadback is equivalent only for field-by-field equality, otherwise coerced with from/to details; viewConditionsAppliedRest:false records that REST data.list --queryCode does not apply fixed conditions",
|
|
16
16
|
configureConditionMap: "queryConditionMap {<schemaCode>: queryConditions[]} is read-derived (query/get with a formCode child-table filter); BizQueryDetailConfig persists queryConditions/querySorts only, so the map is not a configure input",
|
|
17
17
|
configureActions: "actions -> queryActions [{actionCode,name,icon,queryActionType,systemAction,serviceCode,serviceMethod,customService,associationCode,associationType,sortKey}]; queryActionType QueryActionType numeric QUERY(1)/ADD(2)/.../BATCH_SUBMIT(23); associationType QueryActionRelativeType numeric BIZSHEET(0)/WORKFLOW(1); associationCode/associationType are the JSON names of the DTO fields relativeCode/queryActionRelativeType (@JsonProperty); omitted leaves the existing actions untouched, provided MERGES into the effective set by actionCode (live 2026-09-17: query/update replaces-then-re-adds the submitted list, so a merge keeps the platform's built-in 新增/删除/导入/导出 and updates a matching actionCode — replaceActions:true restores the authoritative full set, defaultActions:true re-seeds the platform default set); query/get auto-injects default actions (qr_code/batch_print/batch_update/import_attachment/export_attachment/batch_submit) and query/update resets sortKey to i+1",
|
|
18
18
|
configurePresentation: "presentation -> queryPresentation {clientType,htmlJson,actionsJson,columnsJson,queryViewDataSource,schemaRelations,options}; htmlJson/actionsJson/columnsJson JSON strings are decoded once before render-shape validation (html element tagName+attrs, action actionCode/name/icon, column propertyCode/propertyType); invalid input refuses with listview-presentation-render-invalid before wire and is never double-encoded; clientType is forced to PC by query/update; schemaRelations is platform-derived from the queryColumns tree (resolveRelations) and overwrites your input; a non-empty htmlJson updates the environment record, which query/delete cleans up; omitted leaves the existing presentation untouched (the read-face object must be echoed, because saveBizQueryDetail removes every presentation whose clientType matches before re-adding), provided replaces it",
|
|
@@ -126,7 +126,7 @@ export const LIST_VIEW_LANE_CONTRACT = Object.freeze({
|
|
|
126
126
|
}),
|
|
127
127
|
"listview.configure": Object.freeze({
|
|
128
128
|
scope: LIST_VIEW_SCOPE,
|
|
129
|
-
description: "配置列表视图(列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型)。**code 语义**:省略 `code`(或 code=schemaCode)= 配置**默认视图**(code = 模型 code,8.6.41 起默认视图同样可 configure),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户;仅需第二个视图时才 listview.create(configure 带 code 指向它)。读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options
|
|
129
|
+
description: "配置列表视图(列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型)。**code 语义**:省略 `code`(或 code=schemaCode)= 配置**默认视图**(code = 模型 code,8.6.41 起默认视图同样可 configure),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户;仅需第二个视图时才 listview.create(configure 带 code 指向它)。读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;2.1.5 树视图过滤组三键 `treeLimitScopeType`/`treeLimitConditionGroup`/`treeDefaultConditionGroup` 原样透传(值不同默认拒 `listview-tree-conditions-changed`,确认改写传 `allowTreeConditionChange:true`;缺键拒 `listview-tree-conditions-would-be-lost`);写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
|
|
130
130
|
}),
|
|
131
131
|
"listview.delete": Object.freeze({
|
|
132
132
|
scope: LIST_VIEW_SCOPE,
|
|
@@ -172,7 +172,7 @@ export function assertListViewContract() {
|
|
|
172
172
|
// without a round trip through the artifact.
|
|
173
173
|
assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.get", ["query/get", "code", "默认视图", "present"]);
|
|
174
174
|
assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.list", ["query/list", "code"]);
|
|
175
|
-
assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.configure", ["query/update", "fieldCodes", "默认视图", "querySorts", "queryConditions", "queryActions", "queryActionType", "associationType", "options", "queryPresentation", "htmlJson", "schemaRelations", "customButtons", "customButtonJson", "bindAction", "useLocation", "operateType", "showPermType", "QUERY", "pagingSetting", "listViewModeSetting", "presentationType", "queryGanttModel", "GANTT", "queryLayer", "multiTableHeaderConfig", "publish=TRUE", "field.publish", "rule.enable", "actionConfig", "targetModel", "listview-button-target-unresolved"]);
|
|
175
|
+
assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.configure", ["query/update", "fieldCodes", "默认视图", "querySorts", "queryConditions", "queryActions", "queryActionType", "associationType", "options", "queryPresentation", "htmlJson", "schemaRelations", "customButtons", "customButtonJson", "bindAction", "useLocation", "operateType", "showPermType", "QUERY", "pagingSetting", "listViewModeSetting", "presentationType", "queryGanttModel", "GANTT", "queryLayer", "multiTableHeaderConfig", "publish=TRUE", "field.publish", "rule.enable", "actionConfig", "targetModel", "listview-button-target-unresolved", "treeLimitScopeType", "listview-tree-conditions-changed", "allowTreeConditionChange"]);
|
|
176
176
|
assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.delete", ["query/delete", "absence"]);
|
|
177
177
|
}
|
|
178
178
|
//# sourceMappingURL=list-view-contract.js.map
|
|
@@ -426,6 +426,62 @@ export function treeConditionKeysPresent(row) {
|
|
|
426
426
|
return value !== undefined && value !== null && !(typeof value === "string" && value.trim() === "");
|
|
427
427
|
});
|
|
428
428
|
}
|
|
429
|
+
/** DTO 数字字段:`BizQueryDataRangeCondition.propertyType/operatorType`。 */
|
|
430
|
+
const TREE_NUMERIC_KEYS = new Set(["propertyType", "operatorType"]);
|
|
431
|
+
/**
|
|
432
|
+
* T22:树过滤组值的规范化。平台类型是 `List<List<BizQueryDataRangeCondition>>`
|
|
433
|
+
* (`BizQueryDataRangeCondition.java:13-23`),读面给对象/数组,调用方可能给同一结构
|
|
434
|
+
* 的 JSON 文本(意图面)且键序不保证。规范化:字符串 trim 后以 `[`/`{` 开头则尝试
|
|
435
|
+
* `JSON.parse`;对象按键排序递归;数组逐项递归。`propertyType`/`operatorType` 只做
|
|
436
|
+
* 数字归一(平台 numeric,`"1"` 与 `1` 同值);`value`/`dynamicValue` 保持字符串
|
|
437
|
+
* 严格比较(`"01"` ≠ `"1"`)。
|
|
438
|
+
*/
|
|
439
|
+
export function canonicalTreeValue(value, keyHint) {
|
|
440
|
+
if (typeof value === "string") {
|
|
441
|
+
const trimmed = value.trim();
|
|
442
|
+
if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
|
|
443
|
+
try {
|
|
444
|
+
return canonicalTreeValue(JSON.parse(trimmed), keyHint);
|
|
445
|
+
}
|
|
446
|
+
catch {
|
|
447
|
+
// 不是 JSON:按原字符串比较(不把普通文本当结构改写)
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (keyHint !== undefined && TREE_NUMERIC_KEYS.has(keyHint) && trimmed !== "" && Number.isFinite(Number(trimmed)))
|
|
451
|
+
return Number(trimmed);
|
|
452
|
+
return value;
|
|
453
|
+
}
|
|
454
|
+
if (Array.isArray(value))
|
|
455
|
+
return value.map((entry) => canonicalTreeValue(entry));
|
|
456
|
+
if (value !== null && typeof value === "object") {
|
|
457
|
+
const record = value;
|
|
458
|
+
return Object.fromEntries(Object.keys(record).sort().map((key) => [key, canonicalTreeValue(record[key], key)]));
|
|
459
|
+
}
|
|
460
|
+
return value;
|
|
461
|
+
}
|
|
462
|
+
/** T22:树过滤组值等价(规范化后 JSON 比较;键序与 JSON 文本/对象差异不算变化)。 */
|
|
463
|
+
export function treeConditionValueEqual(left, right) {
|
|
464
|
+
return JSON.stringify(canonicalTreeValue(left)) === JSON.stringify(canonicalTreeValue(right));
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* T22:基线 → 提交的树过滤组逐键差异。`missing` = 基线有值、提交缺键(会被整体
|
|
468
|
+
* 替换静默清掉);`changed` = 两侧都有值但不等。基线没有的键不算漂移(普通视图
|
|
469
|
+
* 与 8.6 因此零影响)。
|
|
470
|
+
*/
|
|
471
|
+
export function diffTreeConditionKeys(baseline, submitted) {
|
|
472
|
+
const missing = [];
|
|
473
|
+
const changed = [];
|
|
474
|
+
const supplied = treeConditionKeysPresent(submitted);
|
|
475
|
+
for (const key of treeConditionKeysPresent(baseline)) {
|
|
476
|
+
if (!supplied.includes(key)) {
|
|
477
|
+
missing.push(key);
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (!treeConditionValueEqual(baseline[key], submitted[key]))
|
|
481
|
+
changed.push({ key, from: baseline[key], to: submitted[key] });
|
|
482
|
+
}
|
|
483
|
+
return { missing, changed };
|
|
484
|
+
}
|
|
429
485
|
/**
|
|
430
486
|
* The keys a list-view condition (a filter CONTROL definition) accepts. Mirrors
|
|
431
487
|
* `com.authine.cloudpivot.metadata.bizquery.BizQueryConditionModel` (8.6.26) at
|