@stalfh233/omc-cli 0.6.34 → 0.6.36
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 +12 -5
- package/dist/recipes/businessrule.js +37 -0
- package/dist/skills.js +16 -12
- package/package.json +3 -3
- package/skills/omc-backend-online-coding.md +102 -7
package/dist/cli.js
CHANGED
|
@@ -1858,7 +1858,7 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1858
1858
|
sectionOrdinal: match.sectionOrdinal,
|
|
1859
1859
|
matchLines: match.matchLines,
|
|
1860
1860
|
sectionBytes: match.sectionBytes,
|
|
1861
|
-
sectionCommand: `omc help ${match.topic} --section
|
|
1861
|
+
sectionCommand: `omc help ${match.topic} --section ${shellQuote(match.heading)}`,
|
|
1862
1862
|
sectionComplete: complete,
|
|
1863
1863
|
...(complete ? { sectionContent: match.section } : { inlineOmitted: `${match.sectionBytes}B 超过单节内联上限 ${SEARCH_INLINE_SECTION_CEILING}B;用 sectionCommand 精确取这一节` }),
|
|
1864
1864
|
};
|
|
@@ -1895,6 +1895,10 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1895
1895
|
console.error(`omc help --search "${query.trim()}":${result.total} 节命中,返回 ${matches.length} 节${truncating || anyOmitted ? "(含未内联正文,见 sectionCommand)" : ""}`);
|
|
1896
1896
|
return emitTransportResult(envelopeFor(matches, truncating), transport);
|
|
1897
1897
|
}
|
|
1898
|
+
/** Quote a heading so `sectionCommand` can be pasted into a POSIX shell. */
|
|
1899
|
+
function shellQuote(value) {
|
|
1900
|
+
return /[`'"$\s]/.test(value) ? `'${value.replace(/'/g, "'\\''")}'` : value;
|
|
1901
|
+
}
|
|
1898
1902
|
/**
|
|
1899
1903
|
* Ticket 122 — `omc help [topic]`: the methodology layer, reachable exactly
|
|
1900
1904
|
* like `git help <concept>`. The command list is the "what"; these topics are
|
|
@@ -1956,7 +1960,7 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1956
1960
|
for (const requested of requestedSections) {
|
|
1957
1961
|
const sliced = readSkillSection(topic, requested);
|
|
1958
1962
|
if (sliced?.section)
|
|
1959
|
-
found.push({ section: requested, content: sliced.section, chars: sliced.section.length, bytes: Buffer.byteLength(sliced.section, "utf8") });
|
|
1963
|
+
found.push({ section: sliced.heading ?? requested, ...(sliced.heading !== requested ? { requested } : {}), ...(sliced.matchType === "partial" ? { matchType: "partial" } : {}), content: sliced.section, chars: sliced.section.length, bytes: Buffer.byteLength(sliced.section, "utf8") });
|
|
1960
1964
|
else
|
|
1961
1965
|
missing.push(requested);
|
|
1962
1966
|
}
|
|
@@ -1990,7 +1994,9 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
|
|
|
1990
1994
|
return emitTransportResult({
|
|
1991
1995
|
status: "ok",
|
|
1992
1996
|
topic: sliced.document.name,
|
|
1993
|
-
section: singleSection,
|
|
1997
|
+
section: sliced.heading ?? singleSection,
|
|
1998
|
+
...(sliced.heading !== singleSection || sliced.matchType === "partial" ? { requested: singleSection } : {}),
|
|
1999
|
+
...(sliced.matchType === "partial" ? { matchType: "partial" } : {}),
|
|
1994
2000
|
chars: sliced.section.length,
|
|
1995
2001
|
bytes: Buffer.byteLength(sliced.section, "utf8"),
|
|
1996
2002
|
complete: true,
|
|
@@ -2164,7 +2170,8 @@ async function main() {
|
|
|
2164
2170
|
return CLI_EXIT_CODES.ok;
|
|
2165
2171
|
}
|
|
2166
2172
|
// r30f F15:topic 既是位置参数也接受 `--topic <name>` 别名(肌肉记忆对齐 capability/contract)。
|
|
2167
|
-
|
|
2173
|
+
const collectSection = (value, previous = []) => [...previous, value];
|
|
2174
|
+
command.command("help [topic]").option("--topic <name>", "topic 别名(与位置参数等价:`omc help omc-refusals` = `omc help --topic omc-refusals`)").option("--section [heading]", "按标题取该节内容;可重复或用逗号一次取多节:--section a --section b / --section a,b(不带值则列出该 topic 的节标题)", collectSection, []).option("--sections").option("--all", "回整篇正文(默认只回节索引:标题 + 各节字节)").option("--search <query>", "跨 topic 全文检索(错误码/字段名/命令名);命中节正文随结果返回,不需要再取一次").option("--search-mode <mode>", "all(默认,同一节包含全部词)或 any(包含任一)").option("--limit <n>", "检索最多返回几节(默认 5,1–50)").option("--max-output-bytes <bytes>").action(async (topic, options) => {
|
|
2168
2175
|
const resolvedTopic = typeof options.topic === "string" && options.topic.trim() !== "" ? options.topic.trim() : topic;
|
|
2169
2176
|
commandExitCode = await withTransport(options, request, (transport) => cmdHelp(resolvedTopic, command.commands.map((entry) => entry.name()), transport, options.section, options.sections === true, options.all === true, typeof options.search === "string" ? options.search : undefined, typeof options.searchMode === "string" ? options.searchMode : undefined, typeof options.limit === "string" ? options.limit : undefined));
|
|
2170
2177
|
});
|
|
@@ -2356,7 +2363,7 @@ async function main() {
|
|
|
2356
2363
|
.option("--schema <schemaCode>", "模型 code")
|
|
2357
2364
|
.option("--schema-code <schemaCode>")
|
|
2358
2365
|
.option("--rule-code <ruleCode>")
|
|
2359
|
-
.option("--name <name>", "规则显示名(rule.save 的 name
|
|
2366
|
+
.option("--name <name>", "规则显示名(rule.save 的 name 位;与既有规则同 code 则覆盖更新)。**平台约束:仅中文/字母/数字,长度 1–50**——下划线等符号能落库但设计器无法再编辑(rule-name-invalid 会拦)")
|
|
2360
2367
|
.option("--node-graph <json>", "规则图 {nodes,routes} JSON")
|
|
2361
2368
|
.option("--publish", "保存后同时发布规则版本")
|
|
2362
2369
|
.option("--env <environment>")
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import { environment, model, commonRecovery } from "./shared.js";
|
|
2
|
+
const ruleCustomMinimal = Object.freeze({
|
|
3
|
+
id: "custom-rule-minimal",
|
|
4
|
+
title: "自定义触发规则最小图形状(ruleCode 非平台触发码 → 业务规则面板按钮/API 调用)",
|
|
5
|
+
status: "requires-prior-readback",
|
|
6
|
+
tool: "rule.save",
|
|
7
|
+
args: {
|
|
8
|
+
environment,
|
|
9
|
+
schemaCode: model,
|
|
10
|
+
ruleCode: "<自定义规则 code,如 riskFlagRule>",
|
|
11
|
+
name: "风控标记",
|
|
12
|
+
nodeGraph: {
|
|
13
|
+
nodes: [
|
|
14
|
+
{ nodeCode: "Start", nodeType: "START" },
|
|
15
|
+
// 自定义规则的动作节点按需要选;下面是「写死一个字段」的最小可跑形状
|
|
16
|
+
{ nodeCode: "UPDATE_1", nodeType: "UPDATE", targetObjectCode: model, inputParam: "_input", filterCondition: { mainConditions: [[{ targetSchemaDataItem: "id", ruleConditionType: "EQ", ruleValueType: "DYNAMIC", currentSchemaDataItem: "id" }]], sheetConditions: [] }, dataActions: [{ targetDataItem: "risk_flag", ruleValueType: "FIXED", value: "HIGH", ruleActionType: "EQUALS" }] },
|
|
17
|
+
{ nodeCode: "End", nodeType: "END" },
|
|
18
|
+
],
|
|
19
|
+
routes: [
|
|
20
|
+
{ preNode: "Start", postNode: "UPDATE_1" },
|
|
21
|
+
{ preNode: "UPDATE_1", postNode: "End" },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
preconditions: [
|
|
26
|
+
"ruleCode **不是** Create/Update/Delete/Load/GetList/Cancel/Available 之一,平台就按自定义规则处理(工具自动补 CUSTOM_NODE)。",
|
|
27
|
+
"自定义规则**不会被数据事件自动触发**:要么设计器/按钮调用,要么 `omc call rule.run`,要么 v2/v3 invoke 端点(见 help omc-backend-online-coding §5.1)。",
|
|
28
|
+
],
|
|
29
|
+
conditionalRequirements: [
|
|
30
|
+
"想跑 Java 源码:先用本配方建规则,再 `programming.get` 取模板 → 写 handler → compile → save → publish。",
|
|
31
|
+
"**name 有字符集约束**:仅中文/字母/数字,1–50 字符;下划线会被 rule-name-invalid 拒(能落库但设计器不可编辑)。",
|
|
32
|
+
],
|
|
33
|
+
priorToolReferences: [{ tool: "rule.list", args: { environment, schemaCode: model }, purpose: "确认 ruleCode 未被占用(自定义规则不会自动出现在数据事件列表里,但同名会覆盖)" }],
|
|
34
|
+
dryRun: { supported: true, command: `omc call rule.save --env ${environment} --dry-run --args '<recipe.args>'`, notes: "dry-run 校验 nodeGraph 形状与 ruleCode/name 约束,零 wire" },
|
|
35
|
+
expectedReadback: { performed: { errcode: 0 }, readback: { rulePresent: true }, next: ["rule.enable", "programming.get 取模板", "programming.publish"] },
|
|
36
|
+
refusalRecovery: [{ code: "rule-name-invalid", action: "改 name 为纯中文/字母/数字(去掉下划线等符号);或省略 name 让工具按 ruleCode 生成" }, ...commonRecovery],
|
|
37
|
+
requiresEnvironmentDerivedIds: false,
|
|
38
|
+
});
|
|
2
39
|
const ruleGraph = Object.freeze({
|
|
3
40
|
id: "standard-business-rule-graph",
|
|
4
41
|
title: "保存并启用最小数据事件规则图",
|
package/dist/skills.js
CHANGED
|
@@ -248,13 +248,12 @@ function scanHeadings(lines) {
|
|
|
248
248
|
*/
|
|
249
249
|
function sliceSectionText(lines, start, level) {
|
|
250
250
|
let end = lines.length;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
251
|
+
// Reuse the same fence-aware scan as the section index. A Markdown comment
|
|
252
|
+
// inside a fenced shell/YAML example is not a heading and must not truncate
|
|
253
|
+
// the section body.
|
|
254
|
+
const next = scanHeadings(lines).find((entry) => entry.index > start && entry.level <= level);
|
|
255
|
+
if (next !== undefined)
|
|
256
|
+
end = next.index;
|
|
258
257
|
return lines.slice(start, end).join("\n").trim() + "\n";
|
|
259
258
|
}
|
|
260
259
|
/** Return one Markdown heading and its nested content without loading the full topic into the envelope. */
|
|
@@ -272,7 +271,7 @@ export function readSkillSection(name, requested) {
|
|
|
272
271
|
// full heading ("8. Canonical configuration order(规范配置顺序)") — the
|
|
273
272
|
// route lists headings, but agents also number-jump. Match on the leading
|
|
274
273
|
// ordinal too, so a numeric request does not waste a retry.
|
|
275
|
-
const requestedOrdinal = /^(\d+)(?:[.\)、]|\s|$)/.exec(normalized)?.[1];
|
|
274
|
+
const requestedOrdinal = /^(\d+(?:\.\d+)*)(?:[.\)、]|\s|$)/.exec(normalized)?.[1];
|
|
276
275
|
const matches = (heading) => {
|
|
277
276
|
if (heading === normalized)
|
|
278
277
|
return true;
|
|
@@ -281,25 +280,30 @@ export function readSkillSection(name, requested) {
|
|
|
281
280
|
if (heading.replace(/[^\p{L}\p{N}]+/gu, "-").toLowerCase() === normalized)
|
|
282
281
|
return true;
|
|
283
282
|
if (requestedOrdinal !== undefined) {
|
|
284
|
-
const headingOrdinal = /^(\d+)(?:[.\)、]|\s|$)/.exec(heading)?.[1];
|
|
283
|
+
const headingOrdinal = /^(\d+(?:\.\d+)*)(?:[.\)、]|\s|$)/.exec(heading)?.[1];
|
|
285
284
|
if (headingOrdinal === requestedOrdinal)
|
|
286
285
|
return true;
|
|
287
286
|
}
|
|
288
287
|
return false;
|
|
289
288
|
};
|
|
290
|
-
|
|
289
|
+
const exact = scanned.find((entry) => matches(entry.heading.trim().toLowerCase()));
|
|
290
|
+
let start = exact?.index ?? -1;
|
|
291
|
+
// 精确命中(含序号/归一化形态)即 exact;仅唯一子串回退才降级为 partial。
|
|
292
|
+
let matchType = "exact";
|
|
291
293
|
// Forgiving fallback: a unique prefix/substring match ("流程" for "流程字段权限").
|
|
292
294
|
// A non-unique partial matches nothing (precision over recall) and the
|
|
293
295
|
// not-found error lists the real headings, so the caller can retry once.
|
|
294
296
|
if (start < 0 && normalized.length >= 2) {
|
|
295
297
|
const partial = scanned.filter((entry) => entry.heading.trim().toLowerCase().includes(normalized));
|
|
296
|
-
if (partial.length === 1)
|
|
298
|
+
if (partial.length === 1) {
|
|
297
299
|
start = partial[0].index;
|
|
300
|
+
matchType = "partial";
|
|
301
|
+
}
|
|
298
302
|
}
|
|
299
303
|
if (start < 0)
|
|
300
304
|
return { document, section: "", headings };
|
|
301
305
|
const startEntry = scanned.find((entry) => entry.index === start);
|
|
302
|
-
return { document, section: sliceSectionText(lines, startEntry.index, startEntry.level), headings };
|
|
306
|
+
return { document, section: sliceSectionText(lines, startEntry.index, startEntry.level), headings, heading: startEntry.heading, matchType };
|
|
303
307
|
}
|
|
304
308
|
/**
|
|
305
309
|
* The "shape" of a topic: every heading with the bytes it would cost to read.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.36",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"commander": "14.0.3",
|
|
58
|
-
"omc-core": "0.6.
|
|
58
|
+
"omc-core": "0.6.36",
|
|
59
59
|
"proper-lockfile": "4.1.2",
|
|
60
60
|
"write-file-atomic": "6.0.0",
|
|
61
61
|
"zod": "^3.23.8",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"directory": "packages/omc-cli"
|
|
74
74
|
},
|
|
75
75
|
"optionalDependencies": {
|
|
76
|
-
"@stalfh233/omc-fake-platform": "0.6.
|
|
76
|
+
"@stalfh233/omc-fake-platform": "0.6.36"
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: omc-backend-online-coding
|
|
3
|
-
description: 后端在线编码(CloudPivot 设计时「在线开发」Java 源码)操作手册:选型(在线编码 vs
|
|
3
|
+
description: 后端在线编码(CloudPivot 设计时「在线开发」Java 源码)操作手册:选型(在线编码 vs 二开扩展包)、单条与工作区两种模式、发布语义与模板约束、自动测试闭环、调用面(前端/第三方 invoke)、与 cpdocs 配合、handler 骨架与本机 inject_code_dir 部署坑。写/改/发布业务规则 Java 源码前读。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# 后端在线编码(programming)
|
|
@@ -9,6 +9,11 @@ description: 后端在线编码(CloudPivot 设计时「在线开发」Java 源
|
|
|
9
9
|
从读模板到发布验证的完整闭环。平台事实以 8.6.26 反编译源码为准,live
|
|
10
10
|
AI-Platform 1.1.25(8.7 时代)已实测(2026-11-03)。
|
|
11
11
|
|
|
12
|
+
> **官方参考源**(语雀,6.x 时代 2024——能力边界以本手册实测口径为准):在线开发概述、
|
|
13
|
+
> Handler 开发、规则调用 executeCustomBizRule、invokeBusinessRule、bo/invokeBizRule、
|
|
14
|
+
> 扩展包与在线编码融合;Engine Open API javadoc(docs.cloudpivot.cn → 6.12.0 → OpenEngine)。
|
|
15
|
+
> 本手册的平台事实均带「反编译/真机」出处。
|
|
16
|
+
|
|
12
17
|
## 0. 先分清三个"代码面"
|
|
13
18
|
|
|
14
19
|
| 面 | 是什么 | 用哪个面 |
|
|
@@ -31,10 +36,16 @@ AI-Platform 1.1.25(8.7 时代)已实测(2026-11-03)。
|
|
|
31
36
|
| 版本管理 | 本地 `.omc-programming/` 树 + git | 项目 git |
|
|
32
37
|
|
|
33
38
|
判据:**这段逻辑是不是「某个模型发生某事件时做什么」?** 是 → 在线编码,改完即生效,
|
|
34
|
-
|
|
39
|
+
不用构建部署。需要**通用** REST 端点、跨多模型事务、引第三方 jar → 本地扩展包。
|
|
40
|
+
**例外**:只是「前端/第三方调一条自定义规则拿返回值」→ 在线编码即可——invoke 端点透出
|
|
41
|
+
handle 返回值,可当轻量后端 API(见 §5.1 调用面;8.6.26 反编译 2026-11-10)。
|
|
35
42
|
|
|
36
43
|
先按 cpdocs 的落点判据定「配置 / 二开」;判到二开时,再用上表在两种 Java 落点间选。
|
|
37
44
|
|
|
45
|
+
手工路径(人不用 CLI 时):IDEA 写 → 粘贴设计器「在线编码」界面 save/publish;本地保留
|
|
46
|
+
`.omc-programming/` 同构副本进 git 作回滚依据(published 无 wire 读取端点);平台无乐观锁,
|
|
47
|
+
多端编辑漂移时以平台草稿为准重拉。
|
|
48
|
+
|
|
38
49
|
## 0.1 在线编码的能力边界(实测,1.1.25)
|
|
39
50
|
|
|
40
51
|
在线编码**不是一个工程,是单文件 Handler**。平台契约就是「一条规则 = 一个 `content`
|
|
@@ -75,7 +86,7 @@ Lombok 的代码生成也**不可用**(`@Data` 生成的方法找不到),
|
|
|
75
86
|
| `java.lang/math/util/io` + wildcard / static import | Jakarta EE(`jakarta.*`) |
|
|
76
87
|
| `engine.open.*`(OpenEngine / BizObject / BizObjectQuery / FilterExpression) | **大部分 `engine.api.facade/model.*`**(包不存在) |
|
|
77
88
|
| `engine.ErrorCode`、`engine.api.historical.*` | **`engine.service.*`**(平台内部 Service 不可见) |
|
|
78
|
-
| commons-lang3 / fastjson / guava / hutool / slf4j |
|
|
89
|
+
| commons-lang3 / fastjson / guava / hutool / slf4j | **未部署的工程自有包**(`app.modules.*` 没部署时编不过;已部署进 `extensions/` 的可 import——真机 2026-11-10:import extensions/common 内 jar 的 `app.modules.mcc.*` 编译通过,阴性对照报 package 不存在) |
|
|
79
90
|
| `javax.annotation` / `javax.servlet` | 额外第三方 jar(不在 launcher 类路径上) |
|
|
80
91
|
| Spring 注解(能编译) | **Spring 运行时**(规则每次重新实例化,无容器上下文;不要注册 Bean) |
|
|
81
92
|
|
|
@@ -93,16 +104,17 @@ Lombok 的代码生成也**不可用**(`@Data` 生成的方法找不到),
|
|
|
93
104
|
| 编译产物目录 | `<launcher>/inject_code_dir` | 无写权限 → publish 成功但执行 50000 |
|
|
94
105
|
| 生命周期 | 每次执行重新实例化 | 无状态、不能常驻、不能注册 Bean |
|
|
95
106
|
| 并发/事务 | 跑在平台保存调用内 | 别在里面起线程或长事务 |
|
|
107
|
+
| 注册 Bean 的代价 | **类无法卸载 → 内存泄漏** | 注册 Spring Bean / 持有 Class 引用会钉住类加载器;有状态需求用组合引入,别走容器 |
|
|
96
108
|
|
|
97
109
|
### 必须退回本地扩展包的场景
|
|
98
110
|
|
|
99
111
|
出现任一条就**不是**在线编码能解决的,别硬塞:
|
|
100
112
|
|
|
101
|
-
1.
|
|
113
|
+
1. 要开**通用 REST 端点**(路径自定义、平台级集成)——只「调规则拿返回值」不算,见 §5.1 调用面
|
|
102
114
|
2. 要接 **SPI / 平台扩展点**(单据号、消息、流程监听、适配器、模型校验…)
|
|
103
115
|
3. 要 **Spring 托管 / 拦截器 / 全局异常 / 多 Bean 协作**
|
|
104
|
-
4.
|
|
105
|
-
5. 要<strong>引额外第三方 jar</strong>(launcher
|
|
116
|
+
4. 要复用**未部署**的工程类/工具库——已部署进 `extensions/` 的 jar 类可直接 import(真机 2026-11-10,机制见下「类路径统一模型」)
|
|
117
|
+
5. 要<strong>引额外第三方 jar</strong>(launcher 类路径上没有;部署进 extensions/ 后可达——但那已是扩展包的部署动作)
|
|
106
118
|
6. 要 **Java > 8 语法 / Lombok 代码生成**
|
|
107
119
|
7. 要**多条规则共享同一套工具方法**——在线编码没有跨规则复用,只能各文件复制;
|
|
108
120
|
一旦出现「三处以上重复」,转本地扩展包
|
|
@@ -110,6 +122,20 @@ Lombok 的代码生成也**不可用**(`@Data` 生成的方法找不到),
|
|
|
110
122
|
反过来,**留在在线编码**:某个模型 Create/Update/Delete/Load/GetList/自定义规则时,
|
|
111
123
|
用 OpenEngine 做字段改写、补数、简单联动——publish 即生效。
|
|
112
124
|
|
|
125
|
+
### 类路径统一模型(8.6.26 反编译 + 真机启动参数 2026-11-10)
|
|
126
|
+
|
|
127
|
+
webapi = Spring Boot `PropertiesLauncher`,真机启动参数
|
|
128
|
+
`-Dloader.path=/app/launcher/extensions/,/app/launcher/extensions/common/`——**extensions
|
|
129
|
+
下的 jar 与平台自身同一条类路径**。官方 6.x「web-api 全类路径 / 第三方 jar 可用」的真实
|
|
130
|
+
含义就是「已部署进 extensions 的内容」。在线编码的 javac 类路径直接取自这条 loader.path
|
|
131
|
+
(编译器过滤 BOOT-INF 后 file: URL 直通,`java-parser` Compiler.java),所以已部署扩展类可
|
|
132
|
+
import;但 launcher 自身的嵌套 BOOT-INF lib 对直接 import 仍不可见(`jakarta.*` 编不过的
|
|
133
|
+
边界不变)。
|
|
134
|
+
|
|
135
|
+
**你没法列举已部署的类**:CLI 没有「列出 extensions 内容」的读面(`extensions/` 在远端容器里,
|
|
136
|
+
agent 侧看不到)。判断某个类能不能用只有一条路——写进 handler,`programming.compile` 试一次
|
|
137
|
+
(只读、不落库):成功即可用,`errors[]` 里报 `package ... does not exist` 即不可用。
|
|
138
|
+
|
|
113
139
|
## 1. 两种用法:单条 vs 工作区
|
|
114
140
|
|
|
115
141
|
### 单条(快速改一条规则)
|
|
@@ -258,7 +284,76 @@ public class <schema><rule>Handler extends BaseHandler {
|
|
|
258
284
|
}
|
|
259
285
|
```
|
|
260
286
|
|
|
261
|
-
|
|
287
|
+
### 默认规则是七种(8.6.26 反编译 2026-11-10)
|
|
288
|
+
|
|
289
|
+
`DefaultBusinessRuleType`:**Create / Update / Delete / Load / Cancel(流程作废)/
|
|
290
|
+
Available(流程生效)/ GetList** + 自定义。签名分两档:
|
|
291
|
+
|
|
292
|
+
| 规则 | 覆写签名(handle 已把 Request 存成员变量,无需自取) |
|
|
293
|
+
|---|---|
|
|
294
|
+
| Create | `protected BizObject create(BizObject)` |
|
|
295
|
+
| Update | `protected Object update(BizObject, BizObjectOptions)` |
|
|
296
|
+
| Delete | `protected void delete(BizObject)` |
|
|
297
|
+
| Load | `protected Optional<BizObject> load(BizObject, BizObjectOptions)` |
|
|
298
|
+
| GetList | `protected Page<Map<String,Object>> getList(BizObjectQueryObject)` |
|
|
299
|
+
| Cancel / Available | 空壳——直接覆写 `handle(Request)`,无固定签名 |
|
|
300
|
+
|
|
301
|
+
另有 `TIMING_TASK`(定时任务)规则载体与 `DECISION`(决策表)模式。照 `programming.get`
|
|
302
|
+
返回的模板写最稳。
|
|
303
|
+
|
|
304
|
+
### BizObject.data 系统字段(8.6.26 反编译)
|
|
305
|
+
|
|
306
|
+
主表 14 项:`name / id / workflowInstanceId / sequenceNo / sequenceStatus / owner /
|
|
307
|
+
ownerDeptId / creater / createdDeptId / modifier / createdTime / modifiedTime /
|
|
308
|
+
ownerDeptQueryCode / version`(官方文档只提前 10 项,后 4 项反编译补全);列表行另有
|
|
309
|
+
`rowStatus`。子表系统字段独立一组:`id / parentId / sortKey / modifier / modifiedTime / version`。
|
|
310
|
+
|
|
311
|
+
### 构造约定(8.6.26 反编译)
|
|
312
|
+
|
|
313
|
+
`new BizObject(schemaCode, null, data)` 的 null id 由平台 `genId()` 兜底;**值为 null 的**
|
|
314
|
+
owner/creater/modifier/部门/时间字段才从请求上下文回填(显式传值优先;owner 缺省跟随 creater)。
|
|
315
|
+
|
|
316
|
+
### OpenEngine 语义(8.6.26 反编译;排障高频)
|
|
317
|
+
|
|
318
|
+
- **不是 Spring Bean、非单例**:每次 `generate` 都 new;不要注入、不要缓存引擎实例。
|
|
319
|
+
- 工厂:`OpenEngineFactory.getOpenEngine(OpenEngineContext)` / `getOpenEngine()`;骨架里的
|
|
320
|
+
`this.getOpenEngine(request)` 已封装当前用户(BaseHandler protected 方法)。
|
|
321
|
+
- **`getUserId()` 三级回退:Context → 请求上下文 → null**。异步/系统触发时两者皆无——
|
|
322
|
+
「异步触发里 createBizObject 的 creater 变 null」先想到这儿:显式传
|
|
323
|
+
`OpenEngineContext(currentUserId)` 再调模型/流程 API(引擎内部 20+ 处依赖 getUserId)。
|
|
324
|
+
- 规则间调用:`engine.executeCustomBizRule(schemaCode, bizRuleCode, request)`——可视化规则
|
|
325
|
+
第三参必须是 BizObject(否则 `PARAMETER_SHOULD_BE_BIZOBJECT_FOR_VISUAL`);编码规则不访问
|
|
326
|
+
入参时可传 null;返回值 = 对方 handle 的返回(CODING 模式)。
|
|
327
|
+
|
|
328
|
+
## 5.1 调用面:自定义规则怎么被外部调用(8.6.26 反编译 2026-11-10)
|
|
329
|
+
|
|
330
|
+
自定义规则不止平台按钮能触发——三条消费面,handle 返回值可透出,**可当轻量后端 API**
|
|
331
|
+
(这是 §0.1 退回场景 1 的唯一例外):
|
|
332
|
+
|
|
333
|
+
| 面 | 端点 | 身份 | 返回值形状 |
|
|
334
|
+
|---|---|---|---|
|
|
335
|
+
| 平台按钮 / CLI | `POST /api/api/launcher/domain_service_runtime/<schema>/<rule>`(`omc call rule.run` 即此面) | 会话 | 按钮语义 |
|
|
336
|
+
| 前端 / 站内 | `POST /api/v2/businessRule/invoke`,body `{appCode,schemaCode,businessRuleCode,data}` | RequestContext(无 userId 参数) | **handle 返回值直接 = `ResponseResult.data`** |
|
|
337
|
+
| 第三方 | `POST /api/openapi/v3/bo/invokeBizRule`,body 带 `userId` | OAuth2 client_credentials(`POST /oauth/token` → bearer) | handle 返回值**包在 `returnObject` 里**(不是直接 data) |
|
|
338
|
+
|
|
339
|
+
**两个易混点**:
|
|
340
|
+
- `omc call rule.run` 走的是**第一个面(平台按钮)**,它**不回 handle 的返回 Map**——回执里只有执行结果信封(`effectHint` 明说返回的是执行前快照)。要拿 handle 返回值必须走 v2/v3 的 invoke 端点。
|
|
341
|
+
- 想验规则副作用:写业务字段 → `data.load` 读回。
|
|
342
|
+
|
|
343
|
+
- **硬闸**:两个 invoke 端点都**只接受自定义规则**——Create/Update/Delete/Load/GetList 五个
|
|
344
|
+
默认规则名直接抛 `BUSINESS_RULE_ONLY_SUPPORT_CUSTOM_RUN`(Cancel/Available 由 invokeCustom
|
|
345
|
+
特判逐条执行)。
|
|
346
|
+
- **入参形状分叉**:可视化规则第三参必须 BizObject;编码规则 HTTP body 的 `data`(Map)
|
|
347
|
+
**同时**以 `request.getData().getBizObject()`(BizObject)与 `getCustomParams()`(Map)两个
|
|
348
|
+
形状进入 handle——自定义结构只有编码规则支持。
|
|
349
|
+
- 前端封装:`bizObjectApi.invokeBusinessRule()`(npm 包 cloudpivot-openwebapi,6.13+;官方 6.x 文档)。
|
|
350
|
+
|
|
351
|
+
## 5.2 调试(官方 6.x 知识;融合机制已 8.6.26 反编译+真机确证,操作细节未实测)
|
|
352
|
+
|
|
353
|
+
- **在线编码本地断点 trick(融合路径)**:扩展包里建一个同父类的类 → 规则源码调用它的
|
|
354
|
+
handle → IDEA 断点间接调试(import 扩展类已真机证实可编译,见「类路径统一模型」)。
|
|
355
|
+
- 集群调试需 iphash(请求落同一节点);流程中的规则调试需同步模式(application 配置)。
|
|
356
|
+
- 本地跑 webapi:IDEA「缩短命令行 = classpath file」或 JAR Application 方式。
|
|
262
357
|
|
|
263
358
|
## 6. 本机部署前提(live 踩过的坑)
|
|
264
359
|
|