@stalfh233/omc-cli 0.6.97 → 0.6.99
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/cli.js +62 -7
- package/dist/environment-policy.js +1 -1
- package/dist/lanes/datarule-contract.js +1 -1
- package/dist/lanes/environment.js +17 -19
- package/dist/lanes/perm.js +303 -33
- package/dist/lanes/runtime-data-contract.js +3 -3
- package/dist/lanes/runtime-data.js +33 -2
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +84 -10
- package/dist/path-projection.js +1 -1
- package/dist/read-shapes.js +3 -3
- package/dist/read.js +14 -1
- package/dist/rollback.js +33 -2
- package/dist/session.js +79 -38
- package/dist/write.js +49 -1
- package/package.json +3 -3
- package/skills/omc-write-hazards.md +17 -0
package/dist/lanes/perm.js
CHANGED
|
@@ -44,10 +44,57 @@ function permissionGroupRows(data) {
|
|
|
44
44
|
}
|
|
45
45
|
return nested;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
// 8.7(AI-Platform v1.1.23-dsj.8)的 DataPermissionType 新增 MY_BRANCH_OFFICE=7「同机构」;
|
|
48
|
+
// 未知值原样回传(不降级成 1/6),否则读回后回写会把新权限改坏。
|
|
49
|
+
const permissionType = (v) => ({ 1: "全部可见", 2: "本部门", 3: "仅自己", 4: "自定义", 5: "角色管理范围", 6: "均不可见", 7: "同机构" }[String(v)] ?? (v == null ? null : v));
|
|
48
50
|
const PERMISSION_UPDATE_FUNCTION = "/api/api/system/permission/update_function";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
/**
|
|
52
|
+
* r96(2026-11-24,真机会话 40 次 `perm.auth` 摩擦):动作码此前只活在源码里,
|
|
53
|
+
* `describe perm.auth` 只显示 `grants: array<object>`,非法码只回「未知视图动作码:xxx」
|
|
54
|
+
* ——agent 只能先猜 `add`、再 dry-run 逐个探测。这里把**码 + 中文名 + 平台来源**做成
|
|
55
|
+
* 唯一事实源:错误消息列全(零 tools/list 字节,错误面不进该预算),`labels` 供文档面引用。
|
|
56
|
+
*
|
|
57
|
+
* 平台来源(cp-sources 8.6.26):视图动作 = 列表工具栏按钮
|
|
58
|
+
* (`customButtonViewPerm[].customBtns[].code`),表单动作 = 表单操作按钮
|
|
59
|
+
* (`customButtonFormPerm[].customBtns[].code`)。两族都**大小写敏感、全大写**,
|
|
60
|
+
* 平台未声明的码不会出现(mergeActions 只翻既有按钮的 enable)。
|
|
61
|
+
*/
|
|
62
|
+
const VIEW_ACTION_LABELS = Object.freeze({
|
|
63
|
+
ADD: "新增",
|
|
64
|
+
DELETE: "删除",
|
|
65
|
+
IMPORT: "导入",
|
|
66
|
+
EXPORT: "导出",
|
|
67
|
+
IMPORT_ATTACHMENT: "导入附件",
|
|
68
|
+
EXPORT_ATTACHMENT: "导出附件",
|
|
69
|
+
BATCH_SUBMIT: "批量提交",
|
|
70
|
+
BATCH_UPDATE: "批量修改",
|
|
71
|
+
BATCH_PRINT: "批量打印",
|
|
72
|
+
QR_CODE: "打印二维码",
|
|
73
|
+
EDITOWNER: "修改拥有者",
|
|
74
|
+
// 同步类模型才有(BizQueryController:765 把 MANUAL_SYNC 当查询动作过滤;不在
|
|
75
|
+
// getInitViewButtons 的默认 11 个里)。不列进来就等于「能开不能关」——与完整
|
|
76
|
+
// 期望集语义不一致。子表专用码(CLEAR_ROW/ADD_BEFORE/ADD_AFTER)只在
|
|
77
|
+
// `customButtonFormPerm[].childTableBtns` 里,不属于 actions.view/form,别加。
|
|
78
|
+
MANUAL_SYNC: "同步数据",
|
|
79
|
+
});
|
|
80
|
+
const FORM_ACTION_LABELS = Object.freeze({
|
|
81
|
+
EDIT: "编辑",
|
|
82
|
+
TEMPORARY: "暂存",
|
|
83
|
+
SUBMIT: "提交",
|
|
84
|
+
COPY: "复制",
|
|
85
|
+
PRINT: "打印",
|
|
86
|
+
EDITOWNER: "修改拥有者",
|
|
87
|
+
});
|
|
88
|
+
const VIEW_ACTIONS = new Set(Object.keys(VIEW_ACTION_LABELS));
|
|
89
|
+
const FORM_ACTIONS = new Set(Object.keys(FORM_ACTION_LABELS));
|
|
90
|
+
/**
|
|
91
|
+
* r96:`--param grants` / `--full` 里的动作码教学(嵌套 describe 不进 tools/list)。
|
|
92
|
+
* 与 `actionCodeRefusal` 的错误消息同源,避免两处漂移。
|
|
93
|
+
*/
|
|
94
|
+
function actionCodeDoc(kind) {
|
|
95
|
+
const labels = kind === "view" ? VIEW_ACTION_LABELS : FORM_ACTION_LABELS;
|
|
96
|
+
return `${kind === "view" ? "视图" : "表单"}动作码,全大写:${Object.entries(labels).map(([code, name]) => `${code}=${name}`).join("、")}`;
|
|
97
|
+
}
|
|
51
98
|
function permissionRecords(data) {
|
|
52
99
|
const root = (data && typeof data === "object" ? data : {});
|
|
53
100
|
const records = first(root, "dataPermissionGroups", "functionPermissions", "functions");
|
|
@@ -84,11 +131,37 @@ function mergePropertyPermissions(existing, requested, schemaCode) {
|
|
|
84
131
|
}
|
|
85
132
|
return current;
|
|
86
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* 动作面合并(语义:**每个容器内标准动作码的完整期望集**)。
|
|
136
|
+
*
|
|
137
|
+
* 平台 `customBtns[]` 里不止 11 个枚举码:`CustomButtonPermissionModel.addCustomButtons`
|
|
138
|
+
* 还会把**业务规则绑定的自定义按钮**(code = ruleCode)塞进同一张表。所以这里分两类:
|
|
139
|
+
*
|
|
140
|
+
* - 枚举码(VIEW_ACTIONS/FORM_ACTIONS):完整期望集语义——每个容器全表翻转,
|
|
141
|
+
* 未列出的合法码置 false,并进 `turnedOff` 让它**可见**。
|
|
142
|
+
* - 非枚举码(自定义按钮):只做**显式打开**,绝不隐式关闭。
|
|
143
|
+
*
|
|
144
|
+
* 同一模型可以有多个容器(多列表视图 / 多表单 sheet),所以按容器算:
|
|
145
|
+
* `unapplied` = 所有容器都没有;`partial` = 只在部分容器里有(另一半不会凭空造)。
|
|
146
|
+
*/
|
|
87
147
|
function mergeActions(existing, requested, allowed) {
|
|
88
148
|
if (requested === undefined)
|
|
89
|
-
return existing;
|
|
149
|
+
return { merged: existing, unapplied: [], partial: [], turnedOff: [], turnedOffByContainer: [] };
|
|
90
150
|
const codes = new Set(requested);
|
|
91
|
-
|
|
151
|
+
const containers = rows(existing).map((container) => {
|
|
152
|
+
const record = container;
|
|
153
|
+
return {
|
|
154
|
+
containerCode: first(record, "containerCode") ?? null,
|
|
155
|
+
present: rows(first(record, "customBtns", "actionPermissions")).map((button) => String(button.code ?? "")),
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
const allPresent = new Set(containers.flatMap((container) => container.present));
|
|
159
|
+
const unapplied = requested.filter((code) => !allPresent.has(code));
|
|
160
|
+
const partial = requested.filter((code) => allPresent.has(code) && !containers.every((container) => container.present.includes(code)));
|
|
161
|
+
const turnedOffByContainer = containers
|
|
162
|
+
.map((container) => ({ containerCode: container.containerCode, codes: container.present.filter((code) => allowed.has(code) && !codes.has(code)) }))
|
|
163
|
+
.filter((entry) => entry.codes.length > 0);
|
|
164
|
+
const merged = rows(existing).map((container) => {
|
|
92
165
|
const c = { ...container };
|
|
93
166
|
const buttons = rows(first(c, "customBtns", "actionPermissions"));
|
|
94
167
|
c.customBtns = buttons.map((button) => {
|
|
@@ -96,10 +169,22 @@ function mergeActions(existing, requested, allowed) {
|
|
|
96
169
|
const code = String(b.code ?? "");
|
|
97
170
|
if (allowed.has(code))
|
|
98
171
|
b.enabled = codes.has(code);
|
|
172
|
+
// 自定义按钮:只显式打开,不隐式关闭。
|
|
173
|
+
else if (codes.has(code))
|
|
174
|
+
b.enabled = true;
|
|
99
175
|
return b;
|
|
100
176
|
});
|
|
177
|
+
// 2.1.5(AI-Platform v2.1.5,客户口径 8.8)把按钮权限拆成审批态/查看态:
|
|
178
|
+
// 运行时非审批态**只读** viewCustomBtns/viewChildTableBtns,缺失即空数组
|
|
179
|
+
// (ActionPermissionHandler:91-105);viewBtnPermissionEqualApproval=true 时才
|
|
180
|
+
// 复用审批态集合。旧配置没有这三个字段,2.1.5 上「查看页/已办页按钮会全部消失」。
|
|
181
|
+
// 因此:本工具只改审批态时,若容器没有任何查看态配置,就把查看态显式声明为
|
|
182
|
+
// 「等同审批态」——语义与 8.6 一致,且不改动已有独立查看态配置。
|
|
183
|
+
if (c.viewCustomBtns === undefined && c.viewChildTableBtns === undefined && c.viewBtnPermissionEqualApproval === undefined)
|
|
184
|
+
c.viewBtnPermissionEqualApproval = true;
|
|
101
185
|
return c;
|
|
102
186
|
});
|
|
187
|
+
return { merged, unapplied, partial, turnedOff: [...new Set(turnedOffByContainer.flatMap((entry) => entry.codes))], turnedOffByContainer };
|
|
103
188
|
}
|
|
104
189
|
function authProjection(record) {
|
|
105
190
|
return {
|
|
@@ -152,6 +237,52 @@ function changedProjection(before, after, grant) {
|
|
|
152
237
|
}
|
|
153
238
|
return changes;
|
|
154
239
|
}
|
|
240
|
+
/** 归一化:只做大小写/分隔符折叠,不做模糊匹配(模糊匹配会误杀自定义按钮码)。 */
|
|
241
|
+
const normalizeActionCode = (code) => code.toUpperCase().replace(/[\s_-]/g, "");
|
|
242
|
+
/**
|
|
243
|
+
* 动作码拒绝门(r96)。
|
|
244
|
+
*
|
|
245
|
+
* 只拒**高置信度**的两种错,其余放行交给真机 `unapplied` 回报:
|
|
246
|
+
* 1. 跨族错位(`ADD` 写进 `actions.form`);
|
|
247
|
+
* 2. 仅大小写/分隔符不同(`add` / `IMPORT-ATTACHMENT`)——归一化后与枚举码相等。
|
|
248
|
+
*
|
|
249
|
+
* 不能对任何非枚举码一律拒绝:平台 `customBtns[]` 里还有业务规则绑定的自定义按钮
|
|
250
|
+
* (code = ruleCode,见 `CustomButtonPermissionModel.addCustomButtons`),
|
|
251
|
+
* 一刀切会把合法输入判死。
|
|
252
|
+
*/
|
|
253
|
+
function actionCodeRefusal(kind, code) {
|
|
254
|
+
const labels = kind === "view" ? VIEW_ACTION_LABELS : FORM_ACTION_LABELS;
|
|
255
|
+
const legal = Object.keys(labels);
|
|
256
|
+
const normalized = normalizeActionCode(code);
|
|
257
|
+
const sameFamily = legal.find((candidate) => normalizeActionCode(candidate) === normalized);
|
|
258
|
+
const otherLabels = kind === "view" ? FORM_ACTION_LABELS : VIEW_ACTION_LABELS;
|
|
259
|
+
const otherKind = kind === "view" ? "form" : "view";
|
|
260
|
+
const crossFamily = Object.prototype.hasOwnProperty.call(otherLabels, code.toUpperCase()) ? code.toUpperCase() : undefined;
|
|
261
|
+
const legalText = legal.map((c) => `${c}(${labels[c]})`).join("、");
|
|
262
|
+
const base = {
|
|
263
|
+
status: "refused",
|
|
264
|
+
blocker: "permission-action-unknown",
|
|
265
|
+
kind,
|
|
266
|
+
unknownAction: code,
|
|
267
|
+
acceptedValues: { [`actions.${kind}`]: legal },
|
|
268
|
+
// issue 04 acceptance 点名 supportedActions;与 acceptedValues 同源同值,
|
|
269
|
+
// 两个键都给(前者是本仓惯例,后者是报告里的叫法),避免调用方各猜一个。
|
|
270
|
+
supportedActions: legal,
|
|
271
|
+
nextCommand: `omc describe perm.auth --param grants`,
|
|
272
|
+
};
|
|
273
|
+
if (sameFamily !== undefined)
|
|
274
|
+
return new ToolRefusalError({
|
|
275
|
+
...base,
|
|
276
|
+
didYouMean: { [`actions.${kind}`]: sameFamily },
|
|
277
|
+
message: `未知${kind === "view" ? "视图" : "表单"}动作码:${code}——平台码全大写。是否想写 ${sameFamily}(${labels[sameFamily]})?actions.${kind} 合法值:${legalText}。`,
|
|
278
|
+
});
|
|
279
|
+
if (crossFamily !== undefined)
|
|
280
|
+
return new ToolRefusalError({
|
|
281
|
+
...base,
|
|
282
|
+
message: `未知${kind === "view" ? "视图" : "表单"}动作码:${code}——${crossFamily} 是${otherKind === "view" ? "视图" : "表单"}动作码(actions.${otherKind}),不能放进 actions.${kind}。actions.${kind} 合法值:${legalText}。`,
|
|
283
|
+
});
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
155
286
|
function validateGrants(grants) {
|
|
156
287
|
if (!Array.isArray(grants))
|
|
157
288
|
throw new ToolRefusalError({ status: "refused", blocker: "permission-grants-invalid", message: "grants 必须是数组" });
|
|
@@ -171,13 +302,83 @@ function validateGrants(grants) {
|
|
|
171
302
|
}
|
|
172
303
|
if (grant.rowLevel?.type === 4 && (!Array.isArray(grant.rowLevel.conditions) || grant.rowLevel.conditions.length === 0))
|
|
173
304
|
throw new ToolRefusalError({ status: "refused", blocker: "permission-custom-condition-required", message: "rowLevel.type=4 必须提供非空 conditions" });
|
|
174
|
-
for (const code of grant.actions?.view ?? [])
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
throw
|
|
305
|
+
for (const code of grant.actions?.view ?? []) {
|
|
306
|
+
if (VIEW_ACTIONS.has(code))
|
|
307
|
+
continue;
|
|
308
|
+
const refusal = actionCodeRefusal("view", code);
|
|
309
|
+
if (refusal)
|
|
310
|
+
throw refusal;
|
|
311
|
+
}
|
|
312
|
+
for (const code of grant.actions?.form ?? []) {
|
|
313
|
+
if (FORM_ACTIONS.has(code))
|
|
314
|
+
continue;
|
|
315
|
+
const refusal = actionCodeRefusal("form", code);
|
|
316
|
+
if (refusal)
|
|
317
|
+
throw refusal;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const TURNED_OFF_HINT = "actions 是完整期望集:这些码在本次请求里没列出,因此被置 false;只想加开不想关,请把它们一并写进请求";
|
|
322
|
+
/**
|
|
323
|
+
* r96:把「读到的权限组 + grants」编成要上送的记录(纯函数,零 wire)。
|
|
324
|
+
* dry-run(dryRunPayload)与真写(execute)共用它,保证「预览」和「真写」永远是同一个答案。
|
|
325
|
+
*/
|
|
326
|
+
function planAuthRecords(existing, grants, groupId) {
|
|
327
|
+
const mergedRecords = [];
|
|
328
|
+
const beforeRecords = [];
|
|
329
|
+
const preview = [];
|
|
330
|
+
const unapplied = [];
|
|
331
|
+
const partial = [];
|
|
332
|
+
const turnedOff = [];
|
|
333
|
+
for (const grant of grants) {
|
|
334
|
+
const prior = existing.find((record) => String(first(record, "schemaCode", "functionCode") ?? "") === grant.schemaCode);
|
|
335
|
+
if (!prior)
|
|
336
|
+
throw new ToolRefusalError({ status: "refused", blocker: "permission-target-model-unknown", message: `权限组中不存在模型 ${grant.schemaCode};候选:${existing.map((record) => String(first(record, "schemaCode", "functionCode") ?? "")).filter(Boolean).join(", ")}` });
|
|
337
|
+
beforeRecords.push(prior);
|
|
338
|
+
const merged = { ...prior, permissionGroupId: groupId, schemaCode: grant.schemaCode };
|
|
339
|
+
if (grant.visible !== undefined)
|
|
340
|
+
merged.visibleConfig = { pcAble: grant.visible.pc, mobileAble: grant.visible.mobile };
|
|
341
|
+
if (grant.rowLevel !== undefined) {
|
|
342
|
+
merged.dataPermissionType = grant.rowLevel.type;
|
|
343
|
+
if (grant.rowLevel.conditions !== undefined)
|
|
344
|
+
merged.conditions = grant.rowLevel.conditions;
|
|
345
|
+
}
|
|
346
|
+
if (grant.properties !== undefined)
|
|
347
|
+
merged.propertityPermissionGroups = mergePropertyPermissions(prior.propertityPermissionGroups, grant.properties, grant.schemaCode);
|
|
348
|
+
for (const [kind, requested, allowed, field] of [
|
|
349
|
+
["view", grant.actions?.view, VIEW_ACTIONS, "customButtonViewPerm"],
|
|
350
|
+
["form", grant.actions?.form, FORM_ACTIONS, "customButtonFormPerm"],
|
|
351
|
+
]) {
|
|
352
|
+
if (requested === undefined)
|
|
353
|
+
continue;
|
|
354
|
+
const applied = mergeActions(prior[field], requested, allowed);
|
|
355
|
+
merged[field] = applied.merged;
|
|
356
|
+
preview.push({ schemaCode: grant.schemaCode, kind, requested, unapplied: applied.unapplied, partial: applied.partial, turnedOff: applied.turnedOff, turnedOffByContainer: applied.turnedOffByContainer });
|
|
357
|
+
if (applied.unapplied.length > 0)
|
|
358
|
+
unapplied.push({
|
|
359
|
+
schemaCode: grant.schemaCode,
|
|
360
|
+
kind,
|
|
361
|
+
codes: applied.unapplied,
|
|
362
|
+
hint: `权限组该模型${kind === "view" ? "列表" : "表单"}的全部按钮容器里都没有这些码——平台不会新建按钮;先在该模型的表单/列表设计器里建按钮,或对照 perm.groups 的读回码表`,
|
|
363
|
+
});
|
|
364
|
+
if (applied.partial.length > 0)
|
|
365
|
+
partial.push({
|
|
366
|
+
schemaCode: grant.schemaCode,
|
|
367
|
+
kind,
|
|
368
|
+
codes: applied.partial,
|
|
369
|
+
hint: `这些码只存在于该模型的**部分**${kind === "view" ? "列表视图" : "表单 sheet"}容器里:命中的容器已按请求翻转,缺按钮的容器不会凭空创建(平台只翻既有按钮)`,
|
|
370
|
+
});
|
|
371
|
+
if (applied.turnedOff.length > 0)
|
|
372
|
+
turnedOff.push({
|
|
373
|
+
schemaCode: grant.schemaCode,
|
|
374
|
+
kind,
|
|
375
|
+
codes: applied.turnedOff,
|
|
376
|
+
...(applied.turnedOffByContainer.length > 1 ? { containers: applied.turnedOffByContainer } : {}),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
mergedRecords.push(merged);
|
|
180
380
|
}
|
|
381
|
+
return { mergedRecords, beforeRecords, preview, unapplied, partial, turnedOff };
|
|
181
382
|
}
|
|
182
383
|
export function authSummary(data) {
|
|
183
384
|
const r = (data && typeof data === "object" ? data : {});
|
|
@@ -192,7 +393,7 @@ export function authSummary(data) {
|
|
|
192
393
|
}
|
|
193
394
|
function scopesFor(data) { return rows(data); }
|
|
194
395
|
export function registerPermLane(tools) {
|
|
195
|
-
tools.push(defineTool({ name: "perm.groups", layer: "low", kind: "read", lane: PERM_LANE, scope: PERM_TOOLS["perm.groups"].scope, description: PERM_TOOLS["perm.groups"].description, search: { intents: ["有哪些权限组", "看应用权限包", "权限组清单"] }, inputSchema: { environment: environmentArg, capability: capabilityArg, appCode: z.string().min(1), groupId: z.string().optional(), schemaCode: z.string().optional(), unitId: z.string().optional(), unitType: z.number().int().min(1).max(3).optional() }, handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
396
|
+
tools.push(defineTool({ name: "perm.groups", layer: "low", kind: "read", lane: PERM_LANE, scope: PERM_TOOLS["perm.groups"].scope, description: PERM_TOOLS["perm.groups"].description, search: { intents: ["有哪些权限组", "看应用权限包", "权限组清单"] }, inputSchema: { environment: environmentArg, capability: capabilityArg, appCode: z.string().min(1), groupId: z.string().optional(), schemaCode: z.string().optional(), unitId: z.string().optional(), unitType: z.number().int().min(1).max(3).describe("成员类型:1=部门(DEPT)、2=角色(ROLE)、3=用户(USER);只在按成员反查权限组时使用").optional() }, handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
196
397
|
if (args.groupId || !args.unitId) {
|
|
197
398
|
const path = args.groupId ? ENDPOINTS.permissionGroup : ENDPOINTS.permissionAppPackage;
|
|
198
399
|
const query = args.groupId ? { id: args.groupId, appCode: args.appCode } : { appCode: args.appCode };
|
|
@@ -296,26 +497,95 @@ export function registerPermLane(tools) {
|
|
|
296
497
|
return { userId: args.userId, appCode: args.appCode, adminBypass, ...(adminBypass ? { adminNotice: "管理员会话恒通过,不代表普通用户;本回执是管理员旁路标记。" } : {}), app: { visible: bool(first(data, "visible", "appVisible")), administrator: bool(first(data, "administrator", "isAdministrator")), allVisible: bool(first(data, "allVisible")) }, models: authSummary(data).models, fields: args.schemaCode ? authSummary(data).fields : [], rowLevel: authSummary(data).rowLevel, layers: { configResolvable: true, runtimeSessionRequired: "真实 load/write 判定受对象权限/业务调用/临时流程授权影响——本工具拒绝单值 allow/deny;验证走目标用户会话或 data.load 双读" } };
|
|
297
498
|
}) }));
|
|
298
499
|
writeTool({ tools, name: "perm.assign", lane: PERM_LANE, scope: PERM_TOOLS["perm.assign"].scope, description: PERM_TOOLS["perm.assign"].description, search: { intents: ["把部门加到权限组", "授权权限组", "给权限组加成员"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), units: z.array(z.object({ type: z.enum(["DEPT", "ROLE", "USER"]), id: z.string().min(1), name: z.string().optional() })).min(1), mode: z.enum(["assign", "revoke"]) }, execute: async (session, args) => { const unitType = { DEPT: 1, ROLE: 2, USER: 3 }[args.units[0].type]; const units = args.units.map((u) => ({ unitId: u.id, unitType: { DEPT: 1, ROLE: 2, USER: 3 }[u.type], name: u.name ?? "", corpId: session.enterpriseId(), appCode: args.appCode, groupId: args.groupId })); const body = args.mode === "assign" ? { permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] } : { permGroupIds: [args.groupId], unitIds: args.units.map((u) => u.id), permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] }; const before = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const performed = await wireCall(session, { path: args.mode === "assign" ? ENDPOINTS.permissionAssign : ENDPOINTS.permissionRevoke, method: "POST", body }); const after = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const listAfter = (await wireCall(session, { path: ENDPOINTS.permissionGroupUnits, method: "POST", body: { ...units[0], unitType, appCode: args.appCode, corpId: session.enterpriseId() } })).data; return { performed: { errcode: performed.errcode, mode: args.mode }, readback: { groups: permissionGroupRows(listAfter).map(groupView), source: "post-write listPermissionGroups readback (not write echo)", diff: { before: projectMembers(before), after: projectMembers(after) } } }; } });
|
|
299
|
-
writeTool({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
500
|
+
writeTool({
|
|
501
|
+
tools,
|
|
502
|
+
name: "perm.auth",
|
|
503
|
+
lane: PERM_LANE,
|
|
504
|
+
scope: PERM_TOOLS["perm.auth"].scope,
|
|
505
|
+
description: PERM_TOOLS["perm.auth"].description,
|
|
506
|
+
search: { intents: ["配模型权限", "设行级权限", "配数据权限", "只能看自己的", "别让他看到", "只能看到自己提的", "只能查看自己", "不能看别人的"] },
|
|
507
|
+
inputSchema: {
|
|
508
|
+
appCode: z.string().min(1),
|
|
509
|
+
groupId: z.string().min(1),
|
|
510
|
+
grants: z.array(z.object({
|
|
511
|
+
schemaCode: z.string().min(1),
|
|
512
|
+
visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(),
|
|
513
|
+
rowLevel: z.object({
|
|
514
|
+
type: z.number().int().min(1).max(7).describe("1=全部可见,2=本部门,3=仅自己,4=自定义(须 conditions),5=角色管理范围,6=均不可见,7=同机构(8.7+ 新增,8.6 平台无此值)"),
|
|
515
|
+
conditions: z.array(z.array(z.unknown())).optional(),
|
|
516
|
+
}).optional(),
|
|
517
|
+
properties: z.array(z.object({
|
|
518
|
+
propertyCode: z.string().optional(),
|
|
519
|
+
schemaCode: z.string().optional().describe("可省略,继承 grants.schemaCode"),
|
|
520
|
+
visible: z.boolean().optional(),
|
|
521
|
+
writeAble: z.boolean().optional(),
|
|
522
|
+
decryptAble: z.boolean().optional(),
|
|
523
|
+
})).optional(),
|
|
524
|
+
// r96:动作码此前是 `array<string>`——`--param grants` 只回「字符串数组」,
|
|
525
|
+
// 合法值只在源码里。嵌套 describe 不进 tools/list 投影(只取顶层属性
|
|
526
|
+
// description),所以这两句教学零字节成本地进了 `--param/--full` 面。
|
|
527
|
+
actions: z.object({
|
|
528
|
+
view: z.array(z.string().describe(actionCodeDoc("view"))).optional(),
|
|
529
|
+
form: z.array(z.string().describe(actionCodeDoc("form"))).optional(),
|
|
530
|
+
}).describe("列表/表单动作按钮开关。系统动作码是完整期望集(未列出的会被置 false);自定义按钮码(业务规则绑定的 ruleCode)也可传,但只在既有按钮上显式打开、不会被隐式关闭。平台没有的码不会凭空创建(回执 unapplied)").optional(),
|
|
531
|
+
})).min(1),
|
|
532
|
+
mode: z.enum(["merge"]).default("merge"),
|
|
533
|
+
},
|
|
534
|
+
preflight: (args) => validateGrants(args.grants),
|
|
535
|
+
// r96:dry-run 用 dryRunPayload(只在预览路径跑)而不是 writeLint——后者在真写路径
|
|
536
|
+
// 也会跑一遍,会让每次真写多读一次 297KB 的权限组体。真写与预览仍共用
|
|
537
|
+
// `planAuthRecords`(同一个纯函数),所以两边答案一致。
|
|
538
|
+
// 为什么必须在 dry-run 里说:`actions` 是完整期望集,只传 view:["ADD"] 会把该
|
|
539
|
+
// 模型其余已开按钮一起关掉(本轮真机踩到),而事前的 plan 只有摘要、看不见。
|
|
540
|
+
dryRunPayload: async (session, args) => {
|
|
541
|
+
const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data;
|
|
542
|
+
const planned = planAuthRecords(permissionRecords(group), args.grants, args.groupId);
|
|
543
|
+
return {
|
|
544
|
+
wouldApply: planned.preview.map((entry) => ({
|
|
545
|
+
schemaCode: entry.schemaCode,
|
|
546
|
+
kind: entry.kind,
|
|
547
|
+
enable: entry.requested,
|
|
548
|
+
...(entry.unapplied.length > 0 ? { unapplied: entry.unapplied } : {}),
|
|
549
|
+
...(entry.partial.length > 0 ? { partial: entry.partial } : {}),
|
|
550
|
+
...(entry.turnedOff.length > 0 ? { turnedOff: entry.turnedOff, ...(entry.turnedOffByContainer.length > 1 ? { turnedOffByContainer: entry.turnedOffByContainer } : {}) } : {}),
|
|
551
|
+
})),
|
|
552
|
+
...(planned.unapplied.length > 0 ? { unapplied: planned.unapplied } : {}),
|
|
553
|
+
...(planned.partial.length > 0 ? { partial: planned.partial } : {}),
|
|
554
|
+
...(planned.turnedOff.length > 0 ? { turnedOff: planned.turnedOff, turnedOffHint: TURNED_OFF_HINT } : {}),
|
|
555
|
+
note: "只读预览:本面读权限组当前按钮表,未做任何写入",
|
|
556
|
+
};
|
|
557
|
+
},
|
|
558
|
+
execute: async (session, args) => {
|
|
559
|
+
const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data;
|
|
560
|
+
const planned = planAuthRecords(permissionRecords(group), args.grants, args.groupId);
|
|
561
|
+
const performed = await wireCall(session, { path: PERMISSION_UPDATE_FUNCTION, method: "POST", body: planned.mergedRecords });
|
|
562
|
+
const refreshed = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data;
|
|
563
|
+
const afterRecords = permissionRecords(refreshed);
|
|
564
|
+
const afterBySchema = new Map(afterRecords.map((record) => [String(first(record, "schemaCode", "functionCode") ?? ""), record]));
|
|
565
|
+
// r96:读回缺席 ≠ 写入成功。过去这里静默回落到 mergedRecords(上送体),
|
|
566
|
+
// 于是「平台没保存」在 diff/models 里看起来像「改成功了」——读回不可信。
|
|
567
|
+
// 现在:缺席的模型不进 models、diff 以 before 对 before(零变化),并点名。
|
|
568
|
+
const readbackMissing = args.grants.map((grant) => grant.schemaCode).filter((schemaCode) => !afterBySchema.has(schemaCode));
|
|
569
|
+
const afterRecordsForDiff = args.grants.map((grant, index) => afterBySchema.get(grant.schemaCode) ?? planned.beforeRecords[index]);
|
|
570
|
+
return {
|
|
571
|
+
performed: { errcode: performed.errcode, endpoint: PERMISSION_UPDATE_FUNCTION },
|
|
572
|
+
readback: {
|
|
573
|
+
// r96:这里原来回**整个权限组原始体(本轮真机实测 297 KB)**,导致
|
|
574
|
+
// `diff/unapplied/turnedOff` 被挤出 stdout 预算、只剩 artifact 指针。
|
|
575
|
+
// 只回本次 grants 涉及的模型投影(与 perm.groups 的 auth 投影同形),
|
|
576
|
+
// 完整组仍可用 perm.groups --groupId 读。
|
|
577
|
+
models: args.grants.filter((grant) => afterBySchema.has(grant.schemaCode)).map((grant) => authProjection(afterBySchema.get(grant.schemaCode))),
|
|
578
|
+
diff: { changed: planned.beforeRecords.flatMap((before, index) => changedProjection(before, afterRecordsForDiff[index], args.grants[index])) },
|
|
579
|
+
...(planned.unapplied.length > 0 ? { unapplied: planned.unapplied } : {}),
|
|
580
|
+
...(planned.partial.length > 0 ? { partial: planned.partial } : {}),
|
|
581
|
+
...(planned.turnedOff.length > 0 ? { turnedOff: planned.turnedOff, turnedOffHint: TURNED_OFF_HINT } : {}),
|
|
582
|
+
...(readbackMissing.length > 0
|
|
583
|
+
? { readbackMissing: { schemaCodes: readbackMissing, hint: "写后读回里没有这些模型——models/diff 对它们不可信(已按「未确认」处理,不回上送体);先用 perm.groups --groupId 复核,别当成功" } }
|
|
584
|
+
: {}),
|
|
585
|
+
readbackHint: "models 只含本次 grants 涉及的模型;完整权限组用 perm.groups --groupId 读",
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
},
|
|
589
|
+
});
|
|
320
590
|
}
|
|
321
591
|
//# sourceMappingURL=perm.js.map
|
|
@@ -43,13 +43,13 @@ export function dataSubmitDescription() {
|
|
|
43
43
|
"Distinct from data.save: data.save persists as DRAFT; data.submit advances the record to COMPLETED (no workflow) or drives the workflow instance.",
|
|
44
44
|
"**审批提交(带 workItemId)可省略 `formData`**:平台使用已存业务数据,且不要携带子表数组;新建记录(无 bizObjectId/workItemId)才必须传 formData。",
|
|
45
45
|
`就地语义:${wire.submitInPlace};无流程 readback 必须确认 objectId 与传入 bizObjectId 相同;无 bizObjectId 的 workflowCode 新建单 → PROCESSING + workflowInstanceId,无流程 → 该行 COMPLETED。`,
|
|
46
|
-
`既有草稿发起流程的唯一支持形状是两段式:先 data.save 带 workflowCode
|
|
46
|
+
`既有草稿发起流程的唯一支持形状是两段式:先 data.save 带 workflowCode 暂存(saveWorkflow→startWorkflow(finishStart=FALSE);getReplayToken 门、sequenceStatus 与返回形状见 data.save 的 workflowCode 段),再以返回的 workItemId 提交(带流程模型提交**必须**带 bizObjectId+workflowInstanceId+workItemId 三元——只带 bizObjectId 会答「流程实例无待办」、只缺 workItemId 会 50000;完整形状见 omc describe data.submit --example workflow-backed-data-submit,待办查询用 workitem.list)。`,
|
|
47
47
|
`仅无 workflowCode/workItemId/workflowInstanceId 且无 bizObjectId 时保留 save→submit 便捷链(新建记录);只要存在 workItemId 或 workflowInstanceId 就 fail-closed 拒绝(blocker submit-biz-object-id-required),零 runtime/form/submit wire。`,
|
|
48
48
|
`formType 自动判定:无任何 workflowCode/workItemId/workflowInstanceId 时**先按模型自动判定**——GET workflow/isworkflow?schemaCode=true 则用 workflow/getWorkflow 解析已发布流程码并**发起流程**(formType="${wire.formTypeWorkflow}",自动先 GET getReplayToken 注入 replayToken,否则 ${wire.replayTokenErrcode} 频繁重复提交);模型无流程 → "${wire.formTypeNoWorkflow}"(无流程提交,走 live 已证链 ${wire.submitChain};单发新建对象会 ${wire.typeCastErrcode},bizObject 勿带字符串 status)或 workItemId+workflowInstanceId(审批待办,agree **顶层**通过/驳回(approval 对象里放 agree 会被静默忽略并按通过处理),**必须带 bizObjectId 指向在途单据**,否则引擎 NPE ${wire.approvalNpeErrcode})→ "${wire.formTypeWorkflow}"。即「无流程直接提交、有流程发起流程」,不再把有流程模型的新建数据落成游离 sheet 行。`,
|
|
49
|
-
"
|
|
49
|
+
"50000 根因与 app-not-published 见 data.save 同条提示(环境相关、非普遍规律)。",
|
|
50
50
|
"readback.requiredFace:published=已发布表单(权威)/draft=仅草稿/unavailable=读不到(requiredFields:[]≠无必填;真值 form.get --controls)。",
|
|
51
51
|
"Pass `sheetCode` explicitly when the model has multiple sheets; otherwise the default-form sheetCode is resolved from bizsheet/get.",
|
|
52
|
-
"
|
|
52
|
+
"计算字段语义(API 不重算、子表计算字段可能 NPE 50000)见 data.save 的「计算字段」段。",
|
|
53
53
|
]);
|
|
54
54
|
}
|
|
55
55
|
/** Runtime business-object data keyed by field code. */
|
|
@@ -313,6 +313,28 @@ function emptyBusinessProjection(items) {
|
|
|
313
313
|
return items.length > 0 && businessColumns > 0;
|
|
314
314
|
}
|
|
315
315
|
const VIEW_PROJECTION_HINT = "该面仅回视图投影列;业务字段全 null 不代表未写入,真值用 data.load,或用 listview.configure 配列。";
|
|
316
|
+
const PROJECTION_MISS_HINT = "这些字段没有出现在平台返回行里 ≠ 值为空;先查 listview.get 或用 data.load 复核";
|
|
317
|
+
/**
|
|
318
|
+
* Distinguish an omitted wire key from a present empty value. A field is a
|
|
319
|
+
* miss only when it is absent from every returned row; a partial omission is
|
|
320
|
+
* deliberately left alone because it may be row-specific data.
|
|
321
|
+
*/
|
|
322
|
+
function dataListProjectionMiss(rows, requestedFields) {
|
|
323
|
+
if (requestedFields === undefined || rows.length === 0)
|
|
324
|
+
return [];
|
|
325
|
+
return requestedFields.filter((field) => rows.every((row) => {
|
|
326
|
+
const data = row.data && typeof row.data === "object" ? row.data : {};
|
|
327
|
+
return !Object.prototype.hasOwnProperty.call(data, field);
|
|
328
|
+
}));
|
|
329
|
+
}
|
|
330
|
+
function projectionHintWithMiss(hint, projectionMiss) {
|
|
331
|
+
if (projectionMiss.length === 0)
|
|
332
|
+
return hint;
|
|
333
|
+
return {
|
|
334
|
+
...(hint ?? { projectionKnown: false }),
|
|
335
|
+
hint: `${hint?.hint ?? ""}${hint?.hint ? ";" : ""}${PROJECTION_MISS_HINT}`,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
316
338
|
/**
|
|
317
339
|
* 从 items 里找「null 业务列」(跨行全 null;任何一行有值就算已投影有数据),
|
|
318
340
|
* 按视图列证据分类。无 null 业务列时返回 undefined(正常读取零噪音,与旧行为一致)。
|
|
@@ -831,6 +853,11 @@ async function staffStringShapeViolations(session, schemaCode, formData) {
|
|
|
831
853
|
* intent so OMC never reports a successful child write that did not land: a row
|
|
832
854
|
* carrying its own `id` is "Modified", an id-less row is "Added"; an explicit
|
|
833
855
|
* rowStatus is preserved verbatim.
|
|
856
|
+
*
|
|
857
|
+
* 8.7(AI-Platform v1.1.23-dsj.8)新增 `"Sorted"`:排序请求走
|
|
858
|
+
* `subBizObjectSortService.reorder`,必须带既有行 id,重复行 id 直接报参数错误。
|
|
859
|
+
* 8.6 没有这个分支(会被当未知状态 → immutable),所以 `Sorted` 只能**原样透传**、
|
|
860
|
+
* 不能由 OMC 自动生成;版本不符时让平台自己的错误说话,别假装排序成功。
|
|
834
861
|
*/
|
|
835
862
|
/**
|
|
836
863
|
* Paths of non-empty child-table arrays anywhere inside a form payload. The
|
|
@@ -1713,12 +1740,13 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1713
1740
|
const selected = fields ?? Object.keys(data).filter((field) => !["id", "bizObjectId", "schemaCode", "sequenceStatus", "createdTime", "updatedTime", "creator", "updater"].includes(field));
|
|
1714
1741
|
return { id: row.bizObjectId ?? row.id ?? data.id, fields: Object.fromEntries(selected.map((field) => [field, data[field] ?? null])) };
|
|
1715
1742
|
});
|
|
1743
|
+
const projectionMissAll = dataListProjectionMiss(collected, fields);
|
|
1716
1744
|
const preview = dataListItemPreview(items);
|
|
1717
1745
|
const nullProjection = items.some((item) => Object.values(item.fields).some((value) => value === null));
|
|
1718
1746
|
// F2(retro 24):出现 null 业务列才读视图证据(正常读取零额外 wire);
|
|
1719
1747
|
// 证据链见 projectionHintFace 的源码注释。
|
|
1720
1748
|
const viewEvidence = nullProjection ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
|
|
1721
|
-
const projectionHintAll = projectionHintFace(items, viewEvidence);
|
|
1749
|
+
const projectionHintAll = projectionHintWithMiss(projectionHintFace(items, viewEvidence), projectionMissAll);
|
|
1722
1750
|
return {
|
|
1723
1751
|
schemaCode: args.schemaCode,
|
|
1724
1752
|
...application,
|
|
@@ -1766,6 +1794,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1766
1794
|
}
|
|
1767
1795
|
: {}),
|
|
1768
1796
|
...(projectionHintAll !== undefined ? { projectionHint: projectionHintAll } : {}),
|
|
1797
|
+
...(projectionMissAll.length > 0 ? { projectionMiss: projectionMissAll } : {}),
|
|
1769
1798
|
items,
|
|
1770
1799
|
};
|
|
1771
1800
|
}
|
|
@@ -1859,6 +1888,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1859
1888
|
const selected = fields ?? Object.keys(data).filter((field) => !["id", "bizObjectId", "schemaCode", "sequenceStatus", "createdTime", "updatedTime", "creator", "updater"].includes(field));
|
|
1860
1889
|
return { id: row.bizObjectId ?? row.id ?? data.id, fields: Object.fromEntries(selected.map((field) => [field, data[field] ?? null])) };
|
|
1861
1890
|
});
|
|
1891
|
+
const projectionMissPaged = dataListProjectionMiss(page.content, fields);
|
|
1862
1892
|
// Live 2026-10-19: when a model has NO configured list view, the
|
|
1863
1893
|
// platform projects only system columns — every business field comes
|
|
1864
1894
|
// back null while `data.load` shows the real values. That reads as
|
|
@@ -1899,7 +1929,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1899
1929
|
// projectionHintFace / listViewProjectionEvidence 的源码注释。
|
|
1900
1930
|
const hasNullValue = items.some((item) => Object.values(item.fields).some((value) => value === null));
|
|
1901
1931
|
const viewEvidence = hasNullValue ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
|
|
1902
|
-
const projectionHintPaged = projectionHintFace(items, viewEvidence);
|
|
1932
|
+
const projectionHintPaged = projectionHintWithMiss(projectionHintFace(items, viewEvidence), projectionMissPaged);
|
|
1903
1933
|
// F6 工单 05b:只有本页行真的内联了子表数组才给一句(否则零字节);
|
|
1904
1934
|
// 取第一条命中行,命令里的 schemaCode/childSchemaCode/bizObjectId 都是真值。
|
|
1905
1935
|
const inlineChild = items
|
|
@@ -1939,6 +1969,7 @@ export function registerRuntimeDataLane(tools) {
|
|
|
1939
1969
|
})(),
|
|
1940
1970
|
...(choiceFilterFields.length > 0 && Number(total ?? 0) === 0 ? { filterValueHint: choiceFilterValueHint(choiceFilterFields) } : {}),
|
|
1941
1971
|
...(projectionHintPaged !== undefined ? { projectionHint: projectionHintPaged } : {}),
|
|
1972
|
+
...(projectionMissPaged.length > 0 ? { projectionMiss: projectionMissPaged } : {}),
|
|
1942
1973
|
totalPages,
|
|
1943
1974
|
itemsCount: items.length,
|
|
1944
1975
|
itemsReturned: items.length,
|
|
@@ -185,7 +185,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
185
185
|
}),
|
|
186
186
|
"workflow.publish": Object.freeze({
|
|
187
187
|
scope: WORKFLOW_SCOPE,
|
|
188
|
-
description: "发布工作流模板(`/api/api/workflow/publish`,raw template JSON body)。`template`
|
|
188
|
+
description: "发布工作流模板(`/api/api/workflow/publish`,raw template JSON body)。`template` **可省略**:省略即把已存草稿原样发布(先 workflow.update 写草稿);要带模板时形状见 `omc describe workflow.update --param template`。",
|
|
189
189
|
}),
|
|
190
190
|
"workflow.bindRule": Object.freeze({
|
|
191
191
|
scope: WORKFLOW_SCOPE,
|