@stalfh233/omc-cli 0.6.81 → 0.6.83
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 +5 -2
- package/dist/artifacts.js +28 -5
- package/dist/capability-overview.js +4 -4
- package/dist/cli.js +168 -41
- package/dist/config-store.js +35 -0
- package/dist/endpoints.js +22 -0
- package/dist/env-export.js +4 -0
- package/dist/human-summary.js +8 -0
- package/dist/lanes/b2-registration-contract.js +11 -0
- package/dist/lanes/b2-registration-coverage.js +1 -0
- package/dist/lanes/businessrule-contract.js +5 -3
- package/dist/lanes/businessrule.js +160 -2
- package/dist/lanes/environment-contract.js +8 -0
- package/dist/lanes/environment.js +73 -0
- package/dist/lanes/rule-graph.js +21 -5
- package/dist/lanes/runtime-data-contract.js +8 -0
- package/dist/lanes/runtime-data.js +99 -12
- package/dist/lanes/servicelog.js +376 -0
- package/dist/lanes/workflow-contract.js +12 -2
- package/dist/lanes/workflow-coverage.js +1 -0
- package/dist/lanes/workflow.js +357 -27
- package/dist/model-purge.js +12 -3
- package/dist/path-projection.js +133 -21
- package/dist/read-shapes.js +14 -9
- package/dist/recipes/businessrule.js +1 -1
- package/dist/refusal-guidance.js +5 -4
- package/dist/rule-support.js +414 -43
- package/dist/session-account.js +66 -0
- package/dist/session.js +27 -0
- package/dist/token-cache.js +3 -0
- package/dist/tool-search.js +5 -1
- package/dist/tool-types.js +3 -1
- package/dist/tools.js +2 -0
- package/dist/writable-window.js +209 -0
- package/package.json +3 -3
- package/skills/omc-capabilities.md +5 -5
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { TokenCache, loginFingerprint } from "./token-cache.js";
|
|
2
|
+
/** JWT payload(claims)——只解不验签:目的是「回执自述」,不是鉴权。 */
|
|
3
|
+
export function decodeJwtPayload(token) {
|
|
4
|
+
const parts = token.split(".");
|
|
5
|
+
if (parts.length < 2)
|
|
6
|
+
return undefined;
|
|
7
|
+
try {
|
|
8
|
+
const decoded = Buffer.from(parts[1], "base64url").toString("utf8");
|
|
9
|
+
const parsed = JSON.parse(decoded);
|
|
10
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
11
|
+
return undefined;
|
|
12
|
+
return parsed;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Decode the session account out of a bearer token. The display name comes from
|
|
20
|
+
* the login face (info_login, cached beside the token) because the JWT itself
|
|
21
|
+
* carries no displayName. Never throws: an undecodable token answers
|
|
22
|
+
* `{unavailableReason}` instead of inventing an identity.
|
|
23
|
+
*/
|
|
24
|
+
export function decodeSessionAccount(token, displayName) {
|
|
25
|
+
const claims = decodeJwtPayload(token);
|
|
26
|
+
if (claims === undefined)
|
|
27
|
+
return { unavailableReason: "token-not-jwt" };
|
|
28
|
+
const id = typeof claims.user_id === "string" ? claims.user_id : undefined;
|
|
29
|
+
if (id === undefined || id.length === 0)
|
|
30
|
+
return { unavailableReason: "token-payload-has-no-user-id" };
|
|
31
|
+
const username = typeof claims.user_name === "string" && claims.user_name.length > 0 ? claims.user_name : undefined;
|
|
32
|
+
return {
|
|
33
|
+
id,
|
|
34
|
+
...(username !== undefined ? { username } : {}),
|
|
35
|
+
...(displayName !== undefined && displayName.length > 0 ? { name: displayName } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The session account a `call` on `environment` would use, read from the local
|
|
40
|
+
* token cache (written by the in-process login of THIS call when it went to the
|
|
41
|
+
* wire; otherwise the credential's last cached token). Zero network. Every
|
|
42
|
+
* failure mode maps to a short `unavailableReason` — the receipt must never
|
|
43
|
+
* lie about who is calling, and must never fail the call itself.
|
|
44
|
+
*/
|
|
45
|
+
export function sessionAccountForEnvironment(store, environment) {
|
|
46
|
+
try {
|
|
47
|
+
const resolved = store.resolveEnvironment(environment);
|
|
48
|
+
try {
|
|
49
|
+
const credential = store.readCredential(resolved.name);
|
|
50
|
+
const cache = new TokenCache(store.configPaths.configPath);
|
|
51
|
+
const cached = cache.load(resolved.name, loginFingerprint(resolved.profile, credential));
|
|
52
|
+
if (cached === undefined)
|
|
53
|
+
return { unavailableReason: "no-cached-token" };
|
|
54
|
+
return decodeSessionAccount(cached.token, cached.accountIdentity);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// credentials unreadable / store absent: not a session yet
|
|
58
|
+
return { unavailableReason: "credential-unavailable" };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// unknown env / cross-environment policy refusal / no default bound
|
|
63
|
+
return { unavailableReason: "environment-unresolved" };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=session-account.js.map
|
package/dist/session.js
CHANGED
|
@@ -21,6 +21,8 @@ export class CloudPivotSession {
|
|
|
21
21
|
tokenCache;
|
|
22
22
|
loginResult;
|
|
23
23
|
version;
|
|
24
|
+
/** r86(retro issue 17):原始版本串("AI-Platform-v1.1.25" 这类含产品线前缀的完整值)。 */
|
|
25
|
+
rawVersion;
|
|
24
26
|
/**
|
|
25
27
|
* Non-fatal login caveats (e.g. the `client` blob in system/config was
|
|
26
28
|
* absent or unreadable, so the token request carried no client_secret).
|
|
@@ -67,6 +69,8 @@ export class CloudPivotSession {
|
|
|
67
69
|
};
|
|
68
70
|
if (cached.version !== undefined) {
|
|
69
71
|
this.version = cached.version;
|
|
72
|
+
if (cached.rawVersion !== undefined)
|
|
73
|
+
this.rawVersion = cached.rawVersion;
|
|
70
74
|
}
|
|
71
75
|
else {
|
|
72
76
|
// Legacy cache written while version evidence was unavailable: probe the
|
|
@@ -77,6 +81,7 @@ export class CloudPivotSession {
|
|
|
77
81
|
.fetchCloudPivotSystemConfig(this.profile.baseUrl, undefined, fetch, core.cloudPivotTenantHeaders(this.profile.engineCode))
|
|
78
82
|
.catch(() => undefined);
|
|
79
83
|
this.version = detectVersion(systemConfig);
|
|
84
|
+
this.rawVersion = detectRawVersion(systemConfig);
|
|
80
85
|
if (this.version !== undefined) {
|
|
81
86
|
this.tokenCache?.save({
|
|
82
87
|
token: cached.token,
|
|
@@ -84,6 +89,7 @@ export class CloudPivotSession {
|
|
|
84
89
|
administrator: cached.administrator,
|
|
85
90
|
...(cached.accountIdentity !== undefined ? { accountIdentity: cached.accountIdentity } : {}),
|
|
86
91
|
version: this.version,
|
|
92
|
+
...(this.rawVersion !== undefined ? { rawVersion: this.rawVersion } : {}),
|
|
87
93
|
});
|
|
88
94
|
}
|
|
89
95
|
}
|
|
@@ -110,12 +116,14 @@ export class CloudPivotSession {
|
|
|
110
116
|
});
|
|
111
117
|
this.loginNotesValue = authenticator.loginNotes();
|
|
112
118
|
this.version = detectVersion(systemConfig);
|
|
119
|
+
this.rawVersion = detectRawVersion(systemConfig);
|
|
113
120
|
this.tokenCache?.save({
|
|
114
121
|
token: this.loginResult.token,
|
|
115
122
|
enterpriseId: this.loginResult.enterpriseId,
|
|
116
123
|
administrator: this.loginResult.administrator,
|
|
117
124
|
...(this.loginResult.accountIdentity !== undefined ? { accountIdentity: this.loginResult.accountIdentity } : {}),
|
|
118
125
|
...(this.version !== undefined ? { version: this.version } : {}),
|
|
126
|
+
...(this.rawVersion !== undefined ? { rawVersion: this.rawVersion } : {}),
|
|
119
127
|
});
|
|
120
128
|
return this.loginResult;
|
|
121
129
|
}
|
|
@@ -123,6 +131,10 @@ export class CloudPivotSession {
|
|
|
123
131
|
detectedVersion() {
|
|
124
132
|
return this.version;
|
|
125
133
|
}
|
|
134
|
+
/** r86(retro issue 17):原始版本串(含产品线前缀);无证据返回 undefined。 */
|
|
135
|
+
rawSystemVersion() {
|
|
136
|
+
return this.rawVersion;
|
|
137
|
+
}
|
|
126
138
|
/** Non-fatal login caveats; empty when the login was fully nominal. */
|
|
127
139
|
loginNotes() {
|
|
128
140
|
return this.loginNotesValue;
|
|
@@ -176,6 +188,7 @@ export class CloudPivotSession {
|
|
|
176
188
|
return first;
|
|
177
189
|
this.loginResult = undefined;
|
|
178
190
|
this.version = undefined;
|
|
191
|
+
this.rawVersion = undefined;
|
|
179
192
|
// The invalidated token must not be re-loaded by the re-login below.
|
|
180
193
|
this.tokenCache?.clear();
|
|
181
194
|
return this.send(input);
|
|
@@ -226,6 +239,20 @@ function detectVersion(systemConfig) {
|
|
|
226
239
|
}
|
|
227
240
|
return undefined;
|
|
228
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* r86(retro issue 17):原始版本键值(如 "AI-Platform-v1.1.25")——detectVersion
|
|
244
|
+
* 只留点号数字段,产品线前缀被丢弃;productVersion 面需要原串(同一 key 优先序)。
|
|
245
|
+
*/
|
|
246
|
+
function detectRawVersion(systemConfig) {
|
|
247
|
+
if (!systemConfig)
|
|
248
|
+
return undefined;
|
|
249
|
+
for (const key of ["version", "sysVersion", "systemVersion", "productVersion", "serverVersion"]) {
|
|
250
|
+
const value = systemConfig[key];
|
|
251
|
+
if (typeof value === "string" && value.trim().length > 0)
|
|
252
|
+
return value.trim();
|
|
253
|
+
}
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
229
256
|
/**
|
|
230
257
|
* A request that produced no response within the timeout. Without this, a
|
|
231
258
|
* stalled CloudPivot (e.g. mid-restart) would leave a write hanging forever and
|
package/dist/token-cache.js
CHANGED
|
@@ -37,6 +37,9 @@ export class TokenCache {
|
|
|
37
37
|
administrator: parsed.administrator,
|
|
38
38
|
...(parsed.accountIdentity !== undefined ? { accountIdentity: parsed.accountIdentity } : {}),
|
|
39
39
|
...(parsed.version !== undefined ? { version: parsed.version } : {}),
|
|
40
|
+
// r86(retro issue 17):白名单漏读会让 productVersion 面在产品线前缀上
|
|
41
|
+
// 永久降级(写进缓存却读不回 → 每次命中都走 detectedVersion 兜底)。
|
|
42
|
+
...(typeof parsed.rawVersion === "string" && parsed.rawVersion.trim().length > 0 ? { rawVersion: parsed.rawVersion } : {}),
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
save(environmentName, fingerprint, login) {
|
package/dist/tool-search.js
CHANGED
|
@@ -5,7 +5,7 @@ const ACTION_VERBS = Object.freeze({
|
|
|
5
5
|
references: "read", inspect: "read", export: "read", check: "read", validate: "read",
|
|
6
6
|
update: "update", publish: "update", enable: "update", disable: "update",
|
|
7
7
|
move: "update", draft: "update", compose: "update", run: "update", link: "update",
|
|
8
|
-
assign: "update", test: "update", bindRule: "update", setButtons: "update",
|
|
8
|
+
assign: "update", test: "update", bindRule: "update", unbindRule: "update", setButtons: "update",
|
|
9
9
|
addPermission: "update", setUserScope: "update", transferDepartment: "update",
|
|
10
10
|
setSummary: "update", runButton: "update", commit: "update", start: "update", addUsers: "update",
|
|
11
11
|
delete: "delete", deleteMany: "delete", disableMany: "delete",
|
|
@@ -147,6 +147,7 @@ const OBJECT_LEXICON = Object.freeze({
|
|
|
147
147
|
datarule: ["字段级规则", "数据规则", "校验规则", "控件规则", "字段校验", "字段级校验"],
|
|
148
148
|
rule: ["业务规则", "规则"],
|
|
149
149
|
rulelog: ["规则执行日志", "规则日志", "执行日志", "触发日志"],
|
|
150
|
+
servicelog: ["业务服务日志", "服务调用日志", "接口调用日志", "调用记录", "集成日志"],
|
|
150
151
|
workflow: ["审批流程", "审批流", "工作流", "流程模板", "流程"],
|
|
151
152
|
workitem: ["待办", "工单"],
|
|
152
153
|
role: ["角色"],
|
|
@@ -225,6 +226,9 @@ const TOOL_PARENTS = Object.freeze({
|
|
|
225
226
|
// 点模型时给 workflow.list 父对象信号(与 listview/form 同族)。
|
|
226
227
|
"workflow.list": ["model"],
|
|
227
228
|
"method.create": ["service"], "method.update": ["service"], "method.get": ["service"], "method.delete": ["service"], "method.test": ["service"], "method.list": ["service"],
|
|
229
|
+
// 业务服务调用日志:对象段是 servicelog,句子里同时点「服务」或「模型/单据」
|
|
230
|
+
// (schemaCode/bizObjectId 是核心过滤面)都该给父对象信号。
|
|
231
|
+
"servicelog.search": ["service", "model"],
|
|
228
232
|
// r83(R79 二期):data.aggregate 是「模型数据的聚合」——句子里点模型时
|
|
229
233
|
// 与 data.list/data.load 同族给出父对象信号(此前只有 data 段命中)。
|
|
230
234
|
"data.aggregate": ["model"],
|
package/dist/tool-types.js
CHANGED
|
@@ -126,7 +126,9 @@ const TOOL_INPUT_ALIASES = Object.freeze({
|
|
|
126
126
|
// 调用方没给 code 时生效;kind=model 想按模型查请显式用 code。
|
|
127
127
|
"rule.references": Object.freeze({ code: ["ruleCode"], schemaCodes: ["schemaCode"] }),
|
|
128
128
|
// r73 探针02-P2:分页条数在 data.list 叫 size,调用方习惯 limit(SQL/REST 肌肉记忆)。
|
|
129
|
-
|
|
129
|
+
// r86(retro issue 16):排序参数名是 orderBy;真机报障的原形是 `sort:[{field,direction}]`
|
|
130
|
+
// (形状与 orderBy 完全一致,见 issue-16)。归一化免得同义键在读面未知键门先被拒。
|
|
131
|
+
"data.list": Object.freeze({ size: ["limit"], orderBy: ["sort"] }),
|
|
130
132
|
});
|
|
131
133
|
/**
|
|
132
134
|
* r54 C② F2:该工具在 TOOL_INPUT_ALIASES 里声明的**同义词键**(调用方可能拿来
|
package/dist/tools.js
CHANGED
|
@@ -21,6 +21,7 @@ import { registerOrganizationLane } from "./lanes/organization.js";
|
|
|
21
21
|
import { registerOnlineJsLane } from "./lanes/online-js.js";
|
|
22
22
|
import { registerProgrammingLane } from "./lanes/programming.js";
|
|
23
23
|
import { registerB2Lane } from "./lanes/b2-registration.js";
|
|
24
|
+
import { registerServiceLogLane } from "./lanes/servicelog.js";
|
|
24
25
|
import { registerListViewLane } from "./lanes/list-view.js";
|
|
25
26
|
import { registerReportLane } from "./lanes/report.js";
|
|
26
27
|
import { registerApplyChangesLane } from "./lanes/apply-changes.js";
|
|
@@ -67,6 +68,7 @@ export function buildToolRegistry() {
|
|
|
67
68
|
registerOnlineJsLane(tools);
|
|
68
69
|
registerProgrammingLane(tools);
|
|
69
70
|
registerB2Lane(tools);
|
|
71
|
+
registerServiceLogLane(tools);
|
|
70
72
|
registerListViewLane(tools);
|
|
71
73
|
registerReportLane(tools);
|
|
72
74
|
registerPermLane(tools);
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { sessionAccountForEnvironment } from "./session-account.js";
|
|
4
|
+
/**
|
|
5
|
+
* Issue 13(retro 2026-11-19):生产写临时开关。
|
|
6
|
+
*
|
|
7
|
+
* 现实流程曾是「备份 omc.config.json → 手改 writable → 写 → 还原备份」:没有
|
|
8
|
+
* 审计、没有到期恢复、多人共用一台机器时状态不可预期。这里把同一件事做成一条
|
|
9
|
+
* 有治理的命令:
|
|
10
|
+
*
|
|
11
|
+
* omc env writable <env> --ttl 10m --reason "..." # 开窗(reason 必填,TTL ≤30m)
|
|
12
|
+
* omc env writable <env> # 查看窗口
|
|
13
|
+
* omc env writable <env> --close # 立即恢复只读
|
|
14
|
+
*
|
|
15
|
+
* 治理语义(与 `writable` 门的关系):
|
|
16
|
+
* - 窗口只把该环境的 `writable` 置 true;生产环境的每笔写**仍然**需要在 args 里
|
|
17
|
+
* 带 confirmProduction:true(两道门并存,窗口不绕过生产确认)。
|
|
18
|
+
* - 到期恢复是**懒检查**:任意 `omc` 命令启动时扫一遍所有环境,过期即恢复
|
|
19
|
+
* writable:false 并清掉窗口记录;没有后台进程。
|
|
20
|
+
* - 每次 open/close/expire 都写配置根下的 append-only `writable-window.log`
|
|
21
|
+
* (一行一事件,JSONL:时间/环境/操作者/reason/TTL/到期时间)。
|
|
22
|
+
*/
|
|
23
|
+
export const WRITABLE_WINDOW_DEFAULT_TTL_MINUTES = 10;
|
|
24
|
+
export const WRITABLE_WINDOW_MAX_TTL_MINUTES = 30;
|
|
25
|
+
export const WRITABLE_WINDOW_LOG = "writable-window.log";
|
|
26
|
+
const REASON_MAX_CHARS = 500;
|
|
27
|
+
export class WritableWindowInputError extends Error {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "WritableWindowInputError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `--ttl 10m` / `10min` / `10` / `1h`。缺省 10 分钟;上限 30 分钟(规格)。
|
|
35
|
+
* 返回分钟数。非法/超限抛 WritableWindowInputError(CLI 映射 invalid-input)。
|
|
36
|
+
*/
|
|
37
|
+
export function parseWritableTtl(raw) {
|
|
38
|
+
if (raw === undefined || raw.trim() === "")
|
|
39
|
+
return WRITABLE_WINDOW_DEFAULT_TTL_MINUTES;
|
|
40
|
+
const match = /^\s*(\d+)\s*(m|min|mins|minute|minutes|h|hr|hour|hours)?\s*$/iu.exec(raw);
|
|
41
|
+
if (match === null)
|
|
42
|
+
throw new WritableWindowInputError(`--ttl 需要像 10m / 1h 这样的时长(默认 ${WRITABLE_WINDOW_DEFAULT_TTL_MINUTES}m,上限 ${WRITABLE_WINDOW_MAX_TTL_MINUTES}m):收到 "${raw}"`);
|
|
43
|
+
const amount = Number(match[1]);
|
|
44
|
+
const unit = (match[2] ?? "m").toLowerCase();
|
|
45
|
+
const minutes = unit.startsWith("h") ? amount * 60 : amount;
|
|
46
|
+
if (!Number.isInteger(minutes) || minutes < 1)
|
|
47
|
+
throw new WritableWindowInputError(`--ttl 至少 1 分钟:收到 "${raw}"`);
|
|
48
|
+
if (minutes > WRITABLE_WINDOW_MAX_TTL_MINUTES)
|
|
49
|
+
throw new WritableWindowInputError(`--ttl 上限 ${WRITABLE_WINDOW_MAX_TTL_MINUTES} 分钟(临时窗口不是长期授权):收到 "${raw}"`);
|
|
50
|
+
return minutes;
|
|
51
|
+
}
|
|
52
|
+
export function validateWritableReason(raw) {
|
|
53
|
+
const reason = raw?.trim() ?? "";
|
|
54
|
+
if (reason === "")
|
|
55
|
+
throw new WritableWindowInputError(`--reason 必填:写清这一次为什么要临时开写(会进 ${WRITABLE_WINDOW_LOG} 审计),如 --reason "修正 orderChange 变更渠道映射"`);
|
|
56
|
+
if (reason.length > REASON_MAX_CHARS)
|
|
57
|
+
throw new WritableWindowInputError(`--reason 最长 ${REASON_MAX_CHARS} 字符(审计一行一事件)`);
|
|
58
|
+
return reason;
|
|
59
|
+
}
|
|
60
|
+
/** sessionAccount → 审计/回执里的可读标签(永不编造身份)。 */
|
|
61
|
+
export function writableWindowOperator(account) {
|
|
62
|
+
if ("unavailableReason" in account)
|
|
63
|
+
return `unavailable:${account.unavailableReason}`;
|
|
64
|
+
const parts = [];
|
|
65
|
+
for (const value of [account.name, account.username, account.id]) {
|
|
66
|
+
if (typeof value === "string" && value.length > 0 && !parts.includes(value))
|
|
67
|
+
parts.push(value);
|
|
68
|
+
}
|
|
69
|
+
return parts.length > 0 ? parts.join(" / ") : `id:${account.id}`;
|
|
70
|
+
}
|
|
71
|
+
/** Append one JSONL event. Best-effort: an audit failure must not undo the gate change. */
|
|
72
|
+
export function appendWritableWindowAudit(store, event) {
|
|
73
|
+
try {
|
|
74
|
+
const path = join(dirname(store.configPaths.configPath), WRITABLE_WINDOW_LOG);
|
|
75
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
76
|
+
appendFileSync(path, JSON.stringify({ ts: new Date().toISOString(), ...event }) + "\n", { mode: 0o600 });
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error(`writable-window 审计写入失败(门已按命令执行):${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function openWritableWindow(store, environment, options) {
|
|
83
|
+
const resolved = store.resolveEnvironment(environment);
|
|
84
|
+
const now = options.now ?? new Date();
|
|
85
|
+
const expiresAt = new Date(now.getTime() + options.ttlMinutes * 60_000);
|
|
86
|
+
const sessionAccount = sessionAccountForEnvironment(store, resolved.name);
|
|
87
|
+
const openedBy = writableWindowOperator(sessionAccount);
|
|
88
|
+
const window = {
|
|
89
|
+
openedBy,
|
|
90
|
+
openedAt: now.toISOString(),
|
|
91
|
+
expiresAt: expiresAt.toISOString(),
|
|
92
|
+
reason: options.reason,
|
|
93
|
+
ttlMinutes: options.ttlMinutes,
|
|
94
|
+
};
|
|
95
|
+
const profile = store.updateEnvironmentProfile(resolved.name, (current) => ({ ...current, writable: true, writableWindow: window }));
|
|
96
|
+
appendWritableWindowAudit(store, {
|
|
97
|
+
event: "open",
|
|
98
|
+
environment: resolved.name,
|
|
99
|
+
operator: openedBy,
|
|
100
|
+
reason: options.reason,
|
|
101
|
+
ttlMinutes: options.ttlMinutes,
|
|
102
|
+
expiresAt: window.expiresAt,
|
|
103
|
+
});
|
|
104
|
+
return { environment: resolved.name, profile, window, sessionAccount };
|
|
105
|
+
}
|
|
106
|
+
export function closeWritableWindow(store, environment, options = {}) {
|
|
107
|
+
const resolved = store.resolveEnvironment(environment);
|
|
108
|
+
const sessionAccount = sessionAccountForEnvironment(store, resolved.name);
|
|
109
|
+
const operator = writableWindowOperator(sessionAccount);
|
|
110
|
+
const current = store.readConfig().environments[resolved.name];
|
|
111
|
+
const previousWindow = current?.writableWindow;
|
|
112
|
+
store.updateEnvironmentProfile(resolved.name, (profile) => {
|
|
113
|
+
const { writableWindow: _dropped, ...rest } = profile;
|
|
114
|
+
return { ...rest, writable: false };
|
|
115
|
+
});
|
|
116
|
+
appendWritableWindowAudit(store, {
|
|
117
|
+
event: "close",
|
|
118
|
+
environment: resolved.name,
|
|
119
|
+
operator,
|
|
120
|
+
reason: previousWindow?.reason ?? "manual-close",
|
|
121
|
+
...(previousWindow !== undefined ? { ttlMinutes: previousWindow.ttlMinutes, expiresAt: previousWindow.expiresAt, openedBy: previousWindow.openedBy } : {}),
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
environment: resolved.name,
|
|
125
|
+
closed: true,
|
|
126
|
+
...(previousWindow !== undefined ? { previousWindow } : {}),
|
|
127
|
+
sessionAccount,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function writableWindowStatus(store, environment, options = {}) {
|
|
131
|
+
const resolved = store.resolveEnvironment(environment);
|
|
132
|
+
const now = options.now ?? new Date();
|
|
133
|
+
const window = resolved.profile.writableWindow;
|
|
134
|
+
return {
|
|
135
|
+
environment: resolved.name,
|
|
136
|
+
writable: resolved.profile.writable === true,
|
|
137
|
+
production: resolved.profile.production === true,
|
|
138
|
+
...(window !== undefined ? { window } : {}),
|
|
139
|
+
expired: window !== undefined && Date.parse(window.expiresAt) <= now.getTime(),
|
|
140
|
+
now: now.toISOString(),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Lazy expiry: restore `writable:false` and drop the window record for every
|
|
145
|
+
* expired environment. Returns what changed so the caller can say one stderr
|
|
146
|
+
* line. Scans ALL configured environments (not just this project's) — a window
|
|
147
|
+
* left open by another project must still expire.
|
|
148
|
+
*/
|
|
149
|
+
export function expireWritableWindows(store, options = {}) {
|
|
150
|
+
const now = options.now ?? new Date();
|
|
151
|
+
const config = store.readConfig();
|
|
152
|
+
const expired = [];
|
|
153
|
+
for (const [environment, profile] of Object.entries(config.environments)) {
|
|
154
|
+
const window = profile.writableWindow;
|
|
155
|
+
if (window === undefined)
|
|
156
|
+
continue;
|
|
157
|
+
if (Date.parse(window.expiresAt) > now.getTime())
|
|
158
|
+
continue;
|
|
159
|
+
expired.push({ environment, window });
|
|
160
|
+
}
|
|
161
|
+
const applied = [];
|
|
162
|
+
for (const { environment, window } of expired) {
|
|
163
|
+
try {
|
|
164
|
+
// Re-read per environment: updateEnvironmentProfile never writes a stale
|
|
165
|
+
// snapshot taken before a concurrent `env writable` finished.
|
|
166
|
+
store.updateEnvironmentProfile(environment, (profile) => {
|
|
167
|
+
const { writableWindow: _dropped, ...rest } = profile;
|
|
168
|
+
return { ...rest, writable: false };
|
|
169
|
+
});
|
|
170
|
+
appendWritableWindowAudit(store, {
|
|
171
|
+
event: "expire",
|
|
172
|
+
environment,
|
|
173
|
+
operator: "auto:ttl-expire",
|
|
174
|
+
openedBy: window.openedBy,
|
|
175
|
+
reason: window.reason,
|
|
176
|
+
ttlMinutes: window.ttlMinutes,
|
|
177
|
+
expiresAt: window.expiresAt,
|
|
178
|
+
});
|
|
179
|
+
applied.push({ environment, window });
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Environment removed / config rewritten mid-sweep: skip it; the next
|
|
183
|
+
// command retries. Never let one bad entry abort the rest.
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return applied;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Called once per CLI process, before command dispatch. Never throws: a broken
|
|
190
|
+
* config is the command's error to report, not the sweeper's. One stderr line
|
|
191
|
+
* only when something actually expired (no background process, no chatter).
|
|
192
|
+
*/
|
|
193
|
+
export function sweepWritableWindowsAtStartup(store) {
|
|
194
|
+
let expired = [];
|
|
195
|
+
try {
|
|
196
|
+
expired = expireWritableWindows(store);
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
if (expired.length > 0) {
|
|
202
|
+
const detail = expired
|
|
203
|
+
.map(({ environment, window }) => `${environment}(到期 ${window.expiresAt},原因:${window.reason})`)
|
|
204
|
+
.join(";");
|
|
205
|
+
console.error(`writable 临时窗口已到期并自动恢复只读:${detail}。审计:${WRITABLE_WINDOW_LOG}`);
|
|
206
|
+
}
|
|
207
|
+
return expired;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=writable-window.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.83",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"commander": "14.0.3",
|
|
59
|
-
"omc-core": "0.6.
|
|
59
|
+
"omc-core": "0.6.83",
|
|
60
60
|
"proper-lockfile": "4.1.2",
|
|
61
61
|
"write-file-atomic": "6.0.0",
|
|
62
62
|
"zod": "^3.23.8",
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"directory": "packages/omc-cli"
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
|
-
"@stalfh233/omc-fake-platform": "0.6.
|
|
77
|
+
"@stalfh233/omc-fake-platform": "0.6.83"
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -168,8 +168,8 @@ only the section for the capability you need —
|
|
|
168
168
|
|
|
169
169
|
## 流程模板 `workflow`
|
|
170
170
|
|
|
171
|
-
- **能做哪些事**:流程模板 workflow.list(应用内流程清单,以模型为索引)、get_draft/get_published、create、update、publish、bindRule
|
|
172
|
-
- **工具**:`workflow.list`、`workflow.get_draft`、`workflow.setButtons`(节点「表单操作」按钮勾选)、`workflow.get_published`、`workflow.validate`、`workflow.create`、`workflow.update`、`workflow.publish`、`workflow.bindRule`、`workflow.delete`、`workflow.permissions`、`workflow.addPermission`、`workflow.removePermission`(发起权限:发布流程不会自动建这一行,缺它一律 40009)、`configure_workflow`、`workitem.list`、`workflow.instanceActivity`、`workflow.transfer`、`workflow.activate`、`workflow.finish`、`org.role.list`、`org.department.list`、`org.user.search`、`org.role.users`、`org.role.userScope`、`org.roleGroup.create`、`org.role.create`、`org.role.update`、`org.role.addUsers`、`org.role.removeUsers`、`org.role.setUserScope`、`org.department.create`、`org.department.update`、`org.department.delete`、`org.department.users`、`org.user.create`、`org.user.update`、`org.user.delete`、`org.user.info`、`org.user.departments`、`org.role.delete`、`org.roleGroup.delete`、`org.user.transferDepartment`
|
|
171
|
+
- **能做哪些事**:流程模板 workflow.list(应用内流程清单,以模型为索引)、get_draft/get_published、create、update、publish、bindRule/unbindRule(事件处理器规则绑定与解绑)、delete、workitem.list、workflow.instanceActivity(实例节点状态诊断);参与人用组织对象。**流程运维三件套**(r64,测试提速定位):workflow.transfer 换审批人(回执 newWorkItems 带补查的新 workItemId)/ workflow.activate 跳转节点 / workflow.finish 手动结束(end 规则照常触发)——运维过的实例不能用于真实流程/权限验证。
|
|
172
|
+
- **工具**:`workflow.list`、`workflow.get_draft`、`workflow.setButtons`(节点「表单操作」按钮勾选)、`workflow.get_published`、`workflow.validate`、`workflow.create`、`workflow.update`、`workflow.publish`、`workflow.bindRule`、`workflow.unbindRule`(镜像 bindRule 两形态做减法;移空按平台 canonical 未绑态写回,不自动 disable 规则)、`workflow.delete`、`workflow.permissions`、`workflow.addPermission`、`workflow.removePermission`(发起权限:发布流程不会自动建这一行,缺它一律 40009)、`configure_workflow`、`workitem.list`、`workflow.instanceActivity`、`workflow.transfer`、`workflow.activate`、`workflow.finish`、`org.role.list`、`org.department.list`、`org.user.search`、`org.role.users`、`org.role.userScope`、`org.roleGroup.create`、`org.role.create`、`org.role.update`、`org.role.addUsers`、`org.role.removeUsers`、`org.role.setUserScope`、`org.department.create`、`org.department.update`、`org.department.delete`、`org.department.users`、`org.user.create`、`org.user.update`、`org.user.delete`、`org.user.info`、`org.user.departments`、`org.role.delete`、`org.roleGroup.delete`、`org.user.transferDepartment`
|
|
173
173
|
- **recipe**:`omc describe workflow.bindRule --example workflow-handler-binding`;条件两级/一级:`omc describe workflow.update --example workflow-conditional-two-level-approval`
|
|
174
174
|
- **边界 / 陷阱**:greenfield 首版;`publish`/`bindRule` 不得在 `ValidateMessage[]` 拒绝时报告成功。运行时 workitem(提交/审批)走 `data.submit`;想知道实例停在哪/是否错派,用 `workflow.instanceActivity`(无 status=1=真停,参与人全是发起人=解析为空退回)。**发起权限**(`workflow.permissions` / `addPermission`)只有部门/角色/用户三种白名单,**没有「全员」选项**——缺权限行时非管理员通常不能发起(40009),想放开只能授一个够宽的部门/角色,不是「不建行=全员」。**行级数据权限 / 可见范围 / 申请人只看自己的单据不在工具覆盖内**(没有按登录人动态过滤的读面/写面);`org.role.setUserScope` 是角色成员的部门管理范围,不是单据行级可见范围。
|
|
175
175
|
|
|
@@ -189,10 +189,10 @@ only the section for the capability you need —
|
|
|
189
189
|
|
|
190
190
|
## 业务集成 `bizservice`
|
|
191
191
|
|
|
192
|
-
- **能做哪些事**:业务服务与方法注册(RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA/SOAP
|
|
193
|
-
- **工具**:`service.list`、`service.get`、`method.list`、`method.get`、`method.update`、`method.create`、`method.delete`、`service.category.list`、`service.category.create`、`service.category.update`、`service.category.delete`、`service.dbconnpool.list`、`service.dbconnpool.create`、`service.dbconnpool.update`、`service.dbconnpool.delete`、`service.adapter_config`、`service.table_list`、`service.table_sql`、`service.register`、`service.update`、`service.delete`、`service.export`、`service.check`、`service.import`、`method.test`
|
|
192
|
+
- **能做哪些事**:业务服务与方法注册(RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA/SOAP)、服务清单(按分类/关键词,凭据不回显)、方法增改删、分类/连接池、导入导出、设计器测试、调用日志(`h_log_biz_service`:params/result/状态/耗时,按单据/服务/方法/时间窗查,无过滤 fail-closed)。
|
|
193
|
+
- **工具**:`service.list`、`service.get`、`method.list`、`method.get`、`method.update`、`method.create`、`method.delete`、`service.category.list`、`service.category.create`、`service.category.update`、`service.category.delete`、`service.dbconnpool.list`、`service.dbconnpool.create`、`service.dbconnpool.update`、`service.dbconnpool.delete`、`service.adapter_config`、`service.table_list`、`service.table_sql`、`service.register`、`service.update`、`service.delete`、`service.export`、`service.check`、`service.import`、`method.test`、`servicelog.search`
|
|
194
194
|
- **recipe**:`omc describe service.register --example restful-query-service`
|
|
195
|
-
- **边界 / 陷阱**:方法 `configJson` 走 AES-128-ECB;**二开接口 = 扩展模块写 REST 接口 + RESTFUL 服务指向它**(页面/规则引用);RESTFUL/DATA_SQL
|
|
195
|
+
- **边界 / 陷阱**:方法 `configJson` 走 AES-128-ECB;**二开接口 = 扩展模块写 REST 接口 + RESTFUL 服务指向它**(页面/规则引用);RESTFUL/DATA_SQL 绑定前须带适配器必需配置(否则是注册壳)。排查「规则到底传了什么参数给接口」用 `servicelog.search`(`bizObjectId`/`schemaCode` 是客户端匹配,`code`/`methodName` 为 LIKE 包含、逗号=精确 IN;params 平台入库上限 2000 字符)。
|
|
196
196
|
|
|
197
197
|
## 报表 `report`
|
|
198
198
|
|