fix: 灰度节点开通加生产硬拦截并拆薄传输层
三处 P0: - 生产企业零拦截:handleGrantNodes 用 isCorpProd 直接拒绝,无 --force 逃生口,且拦截发生在 --yes 确认之前;补 2 条单测。 - dry-run 预览失真:payload 改由编排层显式构造,固定附带开关 (recalculate-the-approval-flow / ui-notification / start) 提为 GRANT_ATTACHED_OPTIONS,dry-run 与成功输出都会展示。刻意不改 真实 payload 语义,避免破坏 Piper 历史接口契约。 - api.ts 越权:只留换票、POST、响应校验;业务码判定与 saved/skipped 映射移到 catalog.ts 的 mapGrantResult。新增 assertNoAuthFailure 复用 EASO 响应体系,401/403 统一转成 AuthenticationError(CLI 退出码 11)。 P1:修 gray-nodes-catalog 同名「数据映射」(mapping/dmn) 静默覆盖, normalizeGrayNodes 遇歧义抛 ValidationError;节点去重;删 node.ts 死常量;Piper 测试域名常量收敛到 core/http;修 filterKw 的 args[1] 越界;归一化逻辑收敛为一份;同步文档与测试名。 校验:bun test 1099 pass / 0 fail,bun run check、check:readme 通过。 本次不打 tag、不触发 Release;Skill 内嵌变更等 0.9.3 发版生效。
This commit is contained in:
1 parent
876dcc7175
commit
8375445bcb
18 files changed
+301
-134
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import { ValidationError } from "../../../../core/errors.js";
|
||||
|
||||
export interface GrayNodeItem {
|
||||
displayName: string;
|
||||
name: string;
|
||||
@@ -121,16 +123,44 @@ export const GRAY_NODES_CATALOG: readonly GrayNodeItem[] = [
|
||||
];
|
||||
|
||||
const typeMap = new Map<string, GrayNodeItem>();
|
||||
const nameMap = new Map<string, GrayNodeItem>();
|
||||
const nameCandidates = new Map<string, GrayNodeItem[]>();
|
||||
|
||||
for (const item of GRAY_NODES_CATALOG) {
|
||||
typeMap.set(item.type.toLowerCase(), item);
|
||||
nameMap.set(item.displayName.toLowerCase(), item);
|
||||
const key = item.displayName.toLowerCase();
|
||||
const bucket = nameCandidates.get(key) ?? [];
|
||||
bucket.push(item);
|
||||
nameCandidates.set(key, bucket);
|
||||
}
|
||||
|
||||
export function findGrayNode(query: string): GrayNodeItem | undefined {
|
||||
export function findGrayNodeCandidates(query: string): GrayNodeItem[] {
|
||||
const q = query.trim().toLowerCase();
|
||||
return typeMap.get(q) || nameMap.get(q);
|
||||
const byType = typeMap.get(q);
|
||||
if (byType) return [byType];
|
||||
return nameCandidates.get(q) ?? [];
|
||||
}
|
||||
|
||||
/** 同名中文节点存在多个类型时返回 undefined,避免静默选中最后一个。 */
|
||||
export function findGrayNode(query: string): GrayNodeItem | undefined {
|
||||
const candidates = findGrayNodeCandidates(query);
|
||||
return candidates.length === 1 ? candidates[0] : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化节点输入:中文名 -> type;同名多类型时抛 ValidationError,
|
||||
* 要求调用方改用明确的 type。清单外的 type 原样保留(灰度清单不是全集)。
|
||||
*/
|
||||
export function normalizeGrayNodes(nodes: string[]): string[] {
|
||||
return nodes.map((raw) => {
|
||||
const q = raw.trim();
|
||||
const candidates = findGrayNodeCandidates(q);
|
||||
if (candidates.length > 1) {
|
||||
throw new ValidationError(
|
||||
`节点名称「${q}」对应多个灰度类型: ${candidates.map((c) => c.type).join(", ")};请改用明确的 type`
|
||||
);
|
||||
}
|
||||
return candidates[0]?.type ?? q;
|
||||
});
|
||||
}
|
||||
|
||||
export function isKnownGrayNodeType(type: string): boolean {
|
||||
|
||||
Reference in new issue
Block a user