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:
@@ -166,6 +166,7 @@ describe("HttpChecker", () => {
|
||||
method: overrides.method ?? "GET",
|
||||
url: overrides.url ?? `${baseUrl}/ok`,
|
||||
},
|
||||
id: "test-http",
|
||||
intervalMs: 60000,
|
||||
name: "test-http",
|
||||
timeoutMs: overrides.timeoutMs ?? 5000,
|
||||
@@ -850,6 +851,7 @@ describe("HttpChecker.resolve", () => {
|
||||
const errors = validateHttpTarget({
|
||||
expect: { status: ["abc"] },
|
||||
http: { url: "https://example.com" },
|
||||
id: "test",
|
||||
name: "test",
|
||||
type: "http",
|
||||
});
|
||||
@@ -858,7 +860,7 @@ describe("HttpChecker.resolve", () => {
|
||||
|
||||
test("ignoreSSL 默认值为 false", () => {
|
||||
const result = checker.resolve(
|
||||
{ http: { url: "https://example.com" }, name: "test", type: "http" },
|
||||
{ http: { url: "https://example.com" }, id: "test", name: "test", type: "http" },
|
||||
makeResolveContext(),
|
||||
);
|
||||
expect(result.http.ignoreSSL).toBe(false);
|
||||
@@ -866,7 +868,7 @@ describe("HttpChecker.resolve", () => {
|
||||
|
||||
test("maxRedirects 默认值为 0", () => {
|
||||
const result = checker.resolve(
|
||||
{ http: { url: "https://example.com" }, name: "test", type: "http" },
|
||||
{ http: { url: "https://example.com" }, id: "test", name: "test", type: "http" },
|
||||
makeResolveContext(),
|
||||
);
|
||||
expect(result.http.maxRedirects).toBe(0);
|
||||
@@ -874,7 +876,13 @@ describe("HttpChecker.resolve", () => {
|
||||
|
||||
test("合法 status 范围模式通过校验", () => {
|
||||
const result = checker.resolve(
|
||||
{ expect: { status: ["2xx", 301] }, http: { url: "https://example.com" }, name: "test", type: "http" },
|
||||
{
|
||||
expect: { status: ["2xx", 301] },
|
||||
http: { url: "https://example.com" },
|
||||
id: "test",
|
||||
name: "test",
|
||||
type: "http",
|
||||
},
|
||||
makeResolveContext(),
|
||||
);
|
||||
expect(result.expect?.status).toEqual(["2xx", 301]);
|
||||
@@ -882,7 +890,12 @@ describe("HttpChecker.resolve", () => {
|
||||
|
||||
test("显式 ignoreSSL 和 maxRedirects 正确解析", () => {
|
||||
const result = checker.resolve(
|
||||
{ http: { ignoreSSL: true, maxRedirects: 3, url: "https://example.com" }, name: "test", type: "http" },
|
||||
{
|
||||
http: { ignoreSSL: true, maxRedirects: 3, url: "https://example.com" },
|
||||
id: "test",
|
||||
name: "test",
|
||||
type: "http",
|
||||
},
|
||||
makeResolveContext(),
|
||||
);
|
||||
expect(result.http.ignoreSSL).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user