@stalfh233/omc-cli 0.8.32 → 0.8.34

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.
Files changed (52) hide show
  1. package/dist/arg-vocabulary.js +223 -0
  2. package/dist/artifact-cmd.js +443 -0
  3. package/dist/batch-call.js +56 -3
  4. package/dist/call-command.js +70 -0
  5. package/dist/call-execute.js +228 -0
  6. package/dist/call-input.js +557 -0
  7. package/dist/call-output.js +240 -0
  8. package/dist/cli.js +13 -1359
  9. package/dist/command-transport.js +4 -1
  10. package/dist/form-support.js +14 -3
  11. package/dist/intent/plan-apply.js +14 -24
  12. package/dist/lanes/datarule.js +21 -0
  13. package/dist/lanes/field-contract.js +1 -1
  14. package/dist/lanes/field.js +128 -1
  15. package/dist/lanes/list-view-shapes.js +8 -1
  16. package/dist/lanes/list-view.js +64 -2
  17. package/dist/lanes/runtime-data/aggregate-support.js +209 -0
  18. package/dist/lanes/runtime-data/aggregate.js +679 -0
  19. package/dist/lanes/runtime-data/field-options.js +52 -0
  20. package/dist/lanes/runtime-data/lane.js +4 -0
  21. package/dist/lanes/runtime-data/record-delete.js +419 -0
  22. package/dist/lanes/runtime-data/record-read.js +984 -0
  23. package/dist/lanes/runtime-data/record-write.js +562 -0
  24. package/dist/lanes/runtime-data/registration.js +22 -0
  25. package/dist/lanes/runtime-data/shapes.js +594 -0
  26. package/dist/lanes/runtime-data/submission.js +1304 -0
  27. package/dist/lanes/runtime-data/write-support.js +875 -0
  28. package/dist/lanes/runtime-data.js +10 -5590
  29. package/dist/lanes/workflow/approval-ops.js +983 -0
  30. package/dist/lanes/workflow/instance-read.js +284 -0
  31. package/dist/lanes/workflow/lifecycle-write.js +1499 -0
  32. package/dist/lanes/workflow/permissions.js +571 -0
  33. package/dist/lanes/workflow/recovery.js +361 -0
  34. package/dist/lanes/workflow/registration.js +14 -0
  35. package/dist/lanes/workflow/shapes.js +811 -0
  36. package/dist/lanes/workflow/template-fetch.js +197 -0
  37. package/dist/lanes/workflow/template-merge.js +1351 -0
  38. package/dist/lanes/workflow/template-read.js +327 -0
  39. package/dist/lanes/workflow.js +11 -6312
  40. package/dist/model-scaffold.js +6 -2
  41. package/dist/plan.js +23 -1
  42. package/dist/read-projection.js +442 -0
  43. package/dist/read.js +40 -335
  44. package/dist/rollback.js +17 -23
  45. package/dist/runtime-support.js +1 -1
  46. package/dist/verification.js +39 -0
  47. package/dist/write-coordinator.js +152 -0
  48. package/dist/write-outcome.js +295 -0
  49. package/dist/write.js +34 -115
  50. package/package.json +3 -3
  51. package/skills/omc-refusals.md +1 -1
  52. package/skills/omc-start-here.md +2 -2
@@ -0,0 +1,209 @@
1
+ import { JSON_COLUMN_NULL_COALESCE, decodeJsonColumn } from "../../json-column.js";
2
+ import { WireError, wireCall, wireRows } from "../../wire.js";
3
+ import { ENDPOINTS } from "../../endpoints.js";
4
+ /** `data.aggregate` caps: server-total counts are exact; the local-scan fallback shares data.list's row cap. */
5
+ export const AGGREGATE_CAP = 1000;
6
+ export const AGGREGATE_PAGE_SIZE = 200;
7
+ /**
8
+ * 0.6.87 D2:策略标记不靠调用方猜 `complete`。
9
+ * - `server-total`:count 走服务端 totalElements(精确);
10
+ * - `paged-local-scan`:本地扫描真的翻了页(pagesConsumed>1);
11
+ * - `local-scan`:本地扫描一页取齐(无分页发生)。
12
+ * `/sum` 命中时另用 `server-aggregate`(D5)。
13
+ */
14
+ export function localScanMode(pagesConsumed) {
15
+ return pagesConsumed > 1 ? "paged-local-scan" : "local-scan";
16
+ }
17
+ /**
18
+ * 0.6.87 D5:`/sum` 的 GET_LIST 守卫(平台证据:
19
+ * `DomainServiceImpl.query` 只在 CODING → SourceCodeLauncher、BIZ_SERVICE →
20
+ * integration 时偏离 DB;默认 GET_LIST 仍 `queryFromDb`;`BizObjectRuleUtils
21
+ * .isOperateDbForQuery` 是同一判据;`/sum` 直接 `aggregateBizObjects` →
22
+ * `executeScalar`,**不经过** `DomainServiceImpl.query`,所以只有「可执行
23
+ * GET_LIST 规则仍读 DB」时两边才是同一真相)。
24
+ *
25
+ * 可证明路径:DRAFT 行的 enabled/status/developmentMode 决定 getExecutable 是否
26
+ * 返回规则;DEFAULT 时执行的是 latest PUBLISH 行,故还要读 runtime 面的
27
+ * PUBLISH 行并核对它的 GET_LIST 节点 dataSourceType。任一步读不到/解析不了 →
28
+ * `isDatabase:false`(不能证明 → 本地扫描),fail closed。
29
+ */
30
+ export const GET_LIST_RULE_CODE = "getlist";
31
+ export function developmentModeName(value) {
32
+ if (typeof value === "number")
33
+ return value === 0 ? "DEFAULT" : value === 1 ? "CODING" : value === 2 ? "DECISION" : String(value);
34
+ return String(value ?? "").toUpperCase();
35
+ }
36
+ export function getListRuleRow(rows) {
37
+ return rows.find((row) => String(row.code ?? "").toLowerCase() === GET_LIST_RULE_CODE);
38
+ }
39
+ export function ruleNodesOf(row) {
40
+ if (row === undefined)
41
+ return undefined;
42
+ const nodes = decodeJsonColumn(row.node, JSON_COLUMN_NULL_COALESCE);
43
+ return Array.isArray(nodes) ? nodes : undefined;
44
+ }
45
+ export async function probeGetListReadsDatabase(session, schemaCode) {
46
+ let wireCalls = 0;
47
+ try {
48
+ // app 面 list 投影 DRAFT 行(getExecutable 的 enabled/status 判据在 DRAFT 上)。
49
+ const drafts = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode } })).data);
50
+ wireCalls += 1;
51
+ const draft = getListRuleRow(drafts);
52
+ if (draft === undefined)
53
+ return { isDatabase: true, wireCalls, reason: "no-get-list-rule" };
54
+ if (draft.enabled === undefined)
55
+ return { isDatabase: false, wireCalls, reason: "get-list-enabled-unknown" };
56
+ if (draft.enabled !== true)
57
+ return { isDatabase: true, wireCalls, reason: "get-list-disabled" };
58
+ if (String(draft.status ?? "").toUpperCase() === "DISABLED")
59
+ return { isDatabase: true, wireCalls, reason: "get-list-disabled" };
60
+ const draftMode = developmentModeName(draft.developmentMode);
61
+ if (draftMode !== "DEFAULT")
62
+ return { isDatabase: false, wireCalls, reason: `get-list-development-mode-${draftMode || "unknown"}` };
63
+ // DEFAULT 时真正执行的是 latest PUBLISH 行,节点以它为准。
64
+ const published = getListRuleRow(wireRows((await wireCall(session, { path: ENDPOINTS.runtimeBusinessRuleListBySchemaCode, query: { schemaCode } })).data));
65
+ wireCalls += 1;
66
+ if (published === undefined)
67
+ return { isDatabase: false, wireCalls, reason: "no-published-get-list" };
68
+ const publishedMode = published.developmentMode === undefined ? "DEFAULT" : developmentModeName(published.developmentMode);
69
+ if (publishedMode !== "DEFAULT")
70
+ return { isDatabase: false, wireCalls, reason: `published-development-mode-${publishedMode || "unknown"}` };
71
+ let nodes = ruleNodesOf(published);
72
+ if (nodes === undefined) {
73
+ const id = typeof published.id === "string" && published.id !== "" ? published.id : undefined;
74
+ if (id === undefined)
75
+ return { isDatabase: false, wireCalls, reason: "get-list-node-unreadable" };
76
+ wireCalls += 1;
77
+ const detail = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
78
+ nodes = ruleNodesOf(detail && typeof detail === "object" ? detail : undefined);
79
+ }
80
+ if (nodes === undefined)
81
+ return { isDatabase: false, wireCalls, reason: "get-list-node-unreadable" };
82
+ const getList = nodes.find((node) => !!node && typeof node === "object" && String(node.nodeType ?? "") === "GET_LIST");
83
+ if (getList === undefined)
84
+ return { isDatabase: false, wireCalls, reason: "get-list-node-missing" };
85
+ const dataSource = getList.dataSourceType;
86
+ const dataSourceName = dataSource === undefined || dataSource === null ? "GET_LIST" : String(dataSource).toUpperCase();
87
+ return { isDatabase: dataSourceName === "GET_LIST", wireCalls, reason: dataSourceName === "GET_LIST" ? "get-list-db" : `get-list-datasource-${dataSourceName}` };
88
+ }
89
+ catch (error) {
90
+ const detail = error instanceof WireError ? (error.errcode !== undefined ? `errcode ${error.errcode}` : error.kind) : "transport";
91
+ return { isDatabase: false, wireCalls, reason: `get-list-probe-failed:${detail}` };
92
+ }
93
+ }
94
+ /**
95
+ * D5:调用平台 `/sum` ALL_DATA 并做**运行时键校验**。后端固定回
96
+ * `{COUNT,SUM,MAX,MIN,AVG}`(`BizObjectFacadeImpl.executeAggregateQueries`,
97
+ * decompiled 5667-5674);键缺失/非数 → 视为形状不符,回退本地扫描而不是猜。
98
+ */
99
+ export async function tryServerSum(session, body, field, metric) {
100
+ try {
101
+ const response = await wireCall(session, {
102
+ path: ENDPOINTS.runtimeQuerySum,
103
+ method: "POST",
104
+ body: { ...body, sumItemList: [{ propertyCode: field, sumDataType: "ALL_DATA" }] },
105
+ });
106
+ const payload = response.data;
107
+ const row = payload && typeof payload === "object" && !Array.isArray(payload) ? payload[field] : undefined;
108
+ if (!row || typeof row !== "object" || Array.isArray(row))
109
+ return { ok: false, reason: "sum-shape-invalid", detail: "missing-field-map" };
110
+ const record = row;
111
+ const count = aggregateNumeric(record.COUNT);
112
+ if (count === null)
113
+ return { ok: false, reason: "sum-shape-invalid", detail: "COUNT" };
114
+ if (count === 0)
115
+ return { ok: true, value: null, nonNullCount: 0 };
116
+ const key = metric === "sum" ? "SUM" : metric === "avg" ? "AVG" : metric === "min" ? "MIN" : "MAX";
117
+ const raw = aggregateNumeric(record[key]);
118
+ if (raw === null)
119
+ return { ok: false, reason: "sum-shape-invalid", detail: key };
120
+ return { ok: true, value: metric === "sum" || metric === "avg" ? aggregateTidy(raw) : raw, nonNullCount: count };
121
+ }
122
+ catch (error) {
123
+ const detail = error instanceof WireError ? (error.errcode !== undefined ? `errcode ${error.errcode}` : error.kind) : "transport";
124
+ return { ok: false, reason: "sum-failed", detail };
125
+ }
126
+ }
127
+ /** 数值聚合的字段拒绝面:publishedFields 只列前 N 个(与 data.list 的过滤目录同口径)。 */
128
+ export const AGGREGATE_FIELD_SAMPLE_LIMIT = 20;
129
+ /**
130
+ * 数值列的 wire 值 → number。null/undefined/非数值字符串 → null(null 行**不进**
131
+ * sum/avg/min/max,也不进 min/max 初值比较)。平台数值列通常回 number,兼容回
132
+ * 数字字符串的形状(历史读回见过)。
133
+ */
134
+ export function aggregateNumeric(value) {
135
+ if (typeof value === "number")
136
+ return Number.isFinite(value) ? value : null;
137
+ if (typeof value === "string" && value.trim() !== "") {
138
+ const parsed = Number(value);
139
+ return Number.isFinite(parsed) ? parsed : null;
140
+ }
141
+ return null;
142
+ }
143
+ /**
144
+ * sum/avg 是**派生值**:12 位有效数字去掉二进制求和噪声(0.1+0.2),不做外推精度、
145
+ * 不改存储值。min/max 是存储值本身,原样返回(tidy 会改掉长整数尾部)。
146
+ */
147
+ export function aggregateTidy(value) {
148
+ return Number.isFinite(value) ? Number(value.toPrecision(12)) : value;
149
+ }
150
+ export function aggregateValue(metric, sum, nonNullCount, min, max) {
151
+ if (nonNullCount === 0)
152
+ return null;
153
+ if (metric === "sum")
154
+ return aggregateTidy(sum);
155
+ if (metric === "avg")
156
+ return aggregateTidy(sum / nonNullCount);
157
+ return metric === "min" ? min : max;
158
+ }
159
+ /**
160
+ * `list_child` 的回执是 `PageVO<Map<String,Object>>`(FormRuntimeController
161
+ * .list_child:1921 `new PageVO(data, queryData.getSize())`):总数在
162
+ * `totalElements`(PageVO.java:40-53),`content` 是**扁平行 map**
163
+ * (`toObjectMap()`),不是 query/list 的 `{bizObjectId,data}` 包装。
164
+ */
165
+ export function childPageOf(payload) {
166
+ const page = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
167
+ const rawTotal = page.totalElements;
168
+ const total = typeof rawTotal === "number" && Number.isFinite(rawTotal) ? rawTotal : null;
169
+ const content = Array.isArray(page.content) ? page.content : [];
170
+ return {
171
+ total,
172
+ rows: content.map((row) => (row && typeof row === "object" ? row : {})),
173
+ };
174
+ }
175
+ /**
176
+ * One property leaf as a level-1 AND group, so it can be appended to ANY base
177
+ * condition (leaf / filters / filterGroup) without re-shaping the existing
178
+ * nesting: level 1 is AND across groups, so `[...base, [[leaf]]]` is exactly
179
+ * `base AND leaf`.
180
+ */
181
+ export function aggregateLeafGroup(propertyCode, propertyType, queryFilterType, propertyValue) {
182
+ return [[{ propertyCode, propertyValue, queryFilterType, propertyType }]];
183
+ }
184
+ export function withAggregateLeaf(condition, leafGroup) {
185
+ return condition === undefined ? [leafGroup] : [...condition, leafGroup];
186
+ }
187
+ /**
188
+ * Draft口径(继承 data.list r26/r28b 的键名,调用方同一套分支)。
189
+ *
190
+ * - `includeDrafts:false`(含 count+groupBy 的默认)→ 注入 sequenceStatus≠DRAFT(excluded);
191
+ * - count 省略 → 平台默认:无条件时含草稿(included),带条件时平台自己排草稿(excluded);
192
+ * - `includeDrafts:true` → 不注入;无条件时含草稿(included),带条件时平台仍排草稿。
193
+ * - 数值指标(numeric)**不做默认排除**:本地折叠只反映平台返回行,要排除须显式 false。
194
+ */
195
+ export function aggregateDraftFilter(excludedByRequest, includeDrafts, hasUserCondition, numeric = false) {
196
+ if (excludedByRequest)
197
+ return { draftPolicy: "excluded", hint: numeric ? "includeDrafts:false——已注入 sequenceStatus≠DRAFT;扫描行与桶只计非草稿" : "includeDrafts:false(groupBy 默认)——已注入 sequenceStatus≠DRAFT;total/桶只计非草稿" };
198
+ if (numeric)
199
+ return {
200
+ draftPolicy: "included",
201
+ hint: `数值指标本地折叠不做默认排除:结果反映平台返回行${hasUserCondition ? "(带条件时平台自身排草稿,r26/r28b)" : ""};要排除草稿显式传 includeDrafts:false`,
202
+ };
203
+ if (includeDrafts && hasUserCondition)
204
+ return { draftPolicy: "excluded", hint: "带条件计数时平台排除草稿(r26/r28b);includeDrafts:true 无法强制包含" };
205
+ if (hasUserCondition)
206
+ return { draftPolicy: "excluded", hint: "带条件计数时平台排除草稿(r26/r28b);无条件时 total 含草稿" };
207
+ return { draftPolicy: "included", hint: includeDrafts ? "无条件计数含草稿(平台口径 r28b);要排除用 includeDrafts:false" : "count 省略 includeDrafts=平台默认:无条件 total 含草稿;要排除显式传 false" };
208
+ }
209
+ //# sourceMappingURL=aggregate-support.js.map