deduplicate task parsing and masking helpers

This commit is contained in:
yml
2026-05-21 18:50:07 +08:00
parent efa41ba976
commit 17a615b8de
9 changed files with 151 additions and 491 deletions
@@ -1,29 +1,16 @@
import {
maskPhone as maskPhoneValue,
maskSecret as maskSecretValue,
} from "../../../utils/masking.js";
type JsonObject = Record<string, any>
export function maskSecret(value: unknown) {
const normalized = String(value || "").trim();
if (!normalized) {
return "";
}
if (normalized.length <= 10) {
return `${normalized.slice(0, 2)}****${normalized.slice(-2)}`;
}
return `${normalized.slice(0, 6)}****${normalized.slice(-6)}`;
return maskSecretValue(value);
}
export function maskPhone(value: unknown) {
const normalized = String(value || "").trim();
if (!normalized) {
return "";
}
if (normalized.length < 7) {
return normalized;
}
return `${normalized.slice(0, 3)}****${normalized.slice(-4)}`;
return maskPhoneValue(value, { maskShort: false });
}
export function mapAdminKuaishouEticketShopItem(item: JsonObject = {}) {