feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -22,6 +22,19 @@ const browserHttpUrl = z
|
||||
}
|
||||
});
|
||||
|
||||
const optionalBrowserHttpUrl = z
|
||||
.string()
|
||||
.trim()
|
||||
.default("")
|
||||
.superRefine((value, context) => {
|
||||
if (!value) return;
|
||||
const parsed = browserHttpUrl.safeParse(value);
|
||||
if (!parsed.success) {
|
||||
context.addIssue({ code: z.ZodIssueCode.custom, message: "必须是安全的 HTTP(S) 地址" });
|
||||
}
|
||||
})
|
||||
.transform((value) => value.replace(/\/+$/, ""));
|
||||
|
||||
const keycloakIssuer = z
|
||||
.string()
|
||||
.trim()
|
||||
@@ -50,10 +63,27 @@ const runtimeConfigSchema = z
|
||||
TJWATER_GEOSERVER_WORKSPACE: z.string().trim().min(1).default("tjwater_next"),
|
||||
TJWATER_SERVER_API_BASE_URL: browserHttpUrl.default("http://127.0.0.1:8000"),
|
||||
TJWATER_AGENT_API_BASE_URL: browserHttpUrl.default("http://127.0.0.1:8787"),
|
||||
TJWATER_WORKBENCH_RUNTIME_MODE: z.enum(["auto", "demo", "history", "backend"]).default("auto"),
|
||||
TJWATER_PERIPHERAL_SAMPLE_API_BASE_URL: optionalBrowserHttpUrl,
|
||||
TJWATER_PERIPHERAL_SAMPLE_TIME_MODE: z.enum(["demo", "recent"]).default("demo"),
|
||||
TJWATER_PERIPHERAL_SAMPLE_DEMO_START: z.string().datetime({ offset: true })
|
||||
.default("2026-09-17T00:00:00Z"),
|
||||
TJWATER_PERIPHERAL_SAMPLE_DEMO_END: z.string().datetime({ offset: true })
|
||||
.default("2026-09-17T12:00:00Z"),
|
||||
TJWATER_PERIPHERAL_SAMPLE_RECENT_HOURS: z.coerce.number().int().min(1).max(168).default(8),
|
||||
TJWATER_ENABLE_DEV_PANEL: runtimeBoolean(false),
|
||||
TJWATER_ENABLE_MSW: runtimeBoolean(false)
|
||||
})
|
||||
.superRefine((config, context) => {
|
||||
const demoStart = Date.parse(config.TJWATER_PERIPHERAL_SAMPLE_DEMO_START);
|
||||
const demoEnd = Date.parse(config.TJWATER_PERIPHERAL_SAMPLE_DEMO_END);
|
||||
if (demoEnd <= demoStart || demoEnd - demoStart > 7 * 24 * 60 * 60 * 1000) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["TJWATER_PERIPHERAL_SAMPLE_DEMO_END"],
|
||||
message: "外围演示窗口必须晚于开始时间且不超过 7 天"
|
||||
});
|
||||
}
|
||||
if (config.TJWATER_AUTH_MODE !== "required") return;
|
||||
if (!config.TJWATER_KEYCLOAK_ISSUER) {
|
||||
context.addIssue({
|
||||
|
||||
Reference in New Issue
Block a user