/** * �?V1.72 文档写入 demovip CC 配置�?env 已对齐时使用)�? * pnpm exec tsx scripts/apply-demovip-cc.ts */ import { getEnv, resetEnvCache } from "../src/lib/env"; import { invalidateCcSettingsCache, testCcLogin, upsertCcSettings, } from "../src/services/cc/settings-config"; import { getCcModeStatus } from "../src/services/cc/mode"; import { prisma } from "../src/services/db"; async function main() { resetEnvCache(); const env = getEnv(); const pub = await upsertCcSettings({ mock: false, apiBase: env.CC_API_BASE, saasHeader: env.CC_SAAS_HEADER, loginMark: env.CC_LOGIN_MARK, username: (env.CC_USERNAME || "fj").trim(), password: (env.CC_PASSWORD_PLAIN || "fj123qwe!").trim(), }); // 文档有真链路的写能力�?live;文档无接口的保�?mock const liveIds = ["save_container", "do_upload"] as const; for (const id of liveIds) { await prisma.ccWriteCapability.upsert({ where: { id }, create: { id, mode: "live", endpoint: id === "save_container" ? "/Container/SaveContainer" : "/Container/SaveFieldValue", }, update: { mode: "live" }, }); } invalidateCcSettingsCache(); const status = await getCcModeStatus(); const login = await testCcLogin(); console.log( JSON.stringify( { settings: pub, mode: status, login, api_base: env.CC_API_BASE, username: env.CC_USERNAME, mock_env: env.CC_MOCK, }, null, 2, ), ); if (!login.ok) process.exit(2); if (!status.live_ready) process.exit(1); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });