feat(platform,datalink,bill): add workflow job drilldown, safe record batch-edit, audit, and spec linkage diagnostics (v0.8.11)

This commit is contained in:
gitea committed 2026-09-29 20:00:55 +08:00
1 parent 2ec08033e0
commit a0ec7f95a7
37 files changed
+3958 -674

No files matched your search

+27 -2
View File
@@ -7,6 +7,10 @@ import {
fetchHoseToken,
EKB_BASE_URL,
} from "./unity-client.js";
import {
canRefreshCorpAccessToken,
refreshSingleCorpAccessToken,
} from "../auth/login.js";
export const SCRIPT_ENGINE_BASE_URL = "https://piper.ekuaibao.com";
@@ -16,9 +20,22 @@ export const PIPER_BASE_URL = SCRIPT_ENGINE_BASE_URL;
// 内存缓存
const scriptEngineMemoryCache = new Map<
string,
{ jwt: string; hoseToken: string; expiresAt: number }
{ jwt: string; hoseToken: string; expiresAt: number; sourceAccessToken?: string }
>();
export function clearScriptEngineClientCache(corpId?: string): void {
if (!corpId) {
scriptEngineMemoryCache.clear();
return;
}
const prefix = `${corpId}:`;
for (const key of scriptEngineMemoryCache.keys()) {
if (key.startsWith(prefix)) {
scriptEngineMemoryCache.delete(key);
}
}
}
function isExpired(entry: { expiresAt: number }, refreshTtl: number): boolean {
return Date.now() >= entry.expiresAt - refreshTtl * 1000;
}
@@ -59,7 +76,7 @@ export async function getScriptEngineClient(
// 检查内存缓存
const mem = scriptEngineMemoryCache.get(cacheKey);
if (mem && !isExpired(mem, refreshTtl)) {
if (mem && mem.sourceAccessToken === corp.credentials.accessToken && !isExpired(mem, refreshTtl)) {
return createAuthClient({
prefixUrl: SCRIPT_ENGINE_BASE_URL,
getHeaders: () => ({
@@ -72,6 +89,13 @@ export async function getScriptEngineClient(
});
}
if (canRefreshCorpAccessToken(corp)) {
const expiresAt = corp.auth?.expiresAt || corp.session?.expTime;
if (!corp.credentials.accessToken || (expiresAt && Date.now() >= expiresAt - refreshTtl * 1000)) {
await refreshSingleCorpAccessToken(corp);
}
}
const corpId = corp.corpId || corp.credentials.corpId;
const staffId = corp.staffId || corp.credentials.staffId;
const environment = resolveCorpCluster(corp);
@@ -94,6 +118,7 @@ export async function getScriptEngineClient(
jwt: easoJwt,
hoseToken,
expiresAt: Date.now() + 2 * 60 * 60 * 1000, // 2小时
sourceAccessToken: corp.credentials.accessToken,
};
scriptEngineMemoryCache.set(cacheKey, entry);