1
0

feat: 配置变量系统与 target id/name 双字段标识

- 新增顶层 variables 段支持 string/number/boolean 字面量
- target 字符串字段支持 、、{...} 转义语法
- 变量解析优先级: variables -> process.env -> 默认值 -> 报错
- 完整引用保留原始类型,部分引用拼接为字符串
- 变量替换在 YAML 解析后、AJV 校验前执行
- 替换仅作用于 targets,跳过 id/type 字段
- target 新增必填 id 字段作为唯一标识,name 改为可选展示名称
- 数据库存储/API/前端全面迁移到 id 标识
- 统一 checker 运行时类型检查为 es-toolkit predicates
- 同步 delta specs 到主 specs,归档 config-variables 变更
This commit is contained in:
2026-05-17 00:37:54 +08:00
parent 366b3211c8
commit 7926514986
53 changed files with 1538 additions and 333 deletions

View File

@@ -41,7 +41,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: errorFailure("exitCode", "spawn", isError(error) ? error.message : String(error)),
matched: false,
statusDetail: null,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -74,7 +74,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: errorFailure("exitCode", "execution", "输出读取失败"),
matched: false,
statusDetail: null,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -90,7 +90,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: errorFailure("exitCode", "output", `输出超过限制 ${t.cmd.maxOutputBytes} 字节`),
matched: false,
statusDetail: `exitCode=${exitCode}`,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -101,7 +101,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: errorFailure("exitCode", "timeout", `命令执行超时 (${t.timeoutMs}ms)`),
matched: false,
statusDetail: null,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -113,7 +113,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: exitCodeResult.failure,
matched: false,
statusDetail: `exitCode=${exitCode}`,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -125,7 +125,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: durationResult.failure,
matched: false,
statusDetail: `exitCode=${exitCode}`,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -138,7 +138,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: stdoutResult.failure,
matched: false,
statusDetail: `exitCode=${exitCode}`,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -152,7 +152,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: stderrResult.failure,
matched: false,
statusDetail: `exitCode=${exitCode}`,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -163,7 +163,7 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
failure: null,
matched: true,
statusDetail: `exitCode=${exitCode}`,
targetName: t.name,
targetId: t.id,
timestamp,
};
}
@@ -189,8 +189,9 @@ export class CommandChecker implements CheckerDefinition<ResolvedCommandTarget>
},
expect: target.expect as CommandExpectConfig | undefined,
group: target.group ?? "default",
id: t.id,
intervalMs: context.defaultIntervalMs,
name: t.name,
name: t.name ?? t.id,
timeoutMs: context.defaultTimeoutMs,
type: "cmd",
} satisfies ResolvedCommandTarget;