Relabel false Didar contact sources as Excel and stop exporting CRM ids as Didar codes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -29,6 +29,20 @@ export function personImportSourceLabel(source: string): string {
|
||||
return source || PERSON_IMPORT_SOURCE_LABELS.manual;
|
||||
}
|
||||
|
||||
/**
|
||||
* کد مبدأ واقعی دیدار برای برچسبزدن منبع.
|
||||
* cuid داخلی مونتاکت و مقادیر توخالی را دیدار حساب نکن
|
||||
* (باگ قبلی: خروجی اکسل id داخلی را در ستون کد دیدار میگذاشت).
|
||||
*/
|
||||
export function resolveDidarSourceRef(raw?: string | null): string | null {
|
||||
const v = String(raw ?? '').trim();
|
||||
if (!v) return null;
|
||||
if (/^(0+|-+|\.+|n\/?a|null|undefined|none)$/i.test(v)) return null;
|
||||
// Prisma/cuid داخلی (~25 کاراکتر با پیشوند c)
|
||||
if (/^c[a-z0-9]{20,32}$/i.test(v)) return null;
|
||||
return v;
|
||||
}
|
||||
|
||||
type SourceSnapshot = {
|
||||
importSource?: string | null;
|
||||
sourceRef?: string | null;
|
||||
@@ -40,8 +54,10 @@ type SourceSnapshot = {
|
||||
function didarIdFrom(customFields: unknown): string | null {
|
||||
if (!customFields || typeof customFields !== 'object') return null;
|
||||
const raw = (customFields as Record<string, unknown>).didarId;
|
||||
if (typeof raw === 'number' && Number.isFinite(raw)) return String(raw);
|
||||
if (typeof raw === 'string' && raw.trim()) return raw.trim();
|
||||
if (typeof raw === 'number' && Number.isFinite(raw)) {
|
||||
return resolveDidarSourceRef(String(raw));
|
||||
}
|
||||
if (typeof raw === 'string') return resolveDidarSourceRef(raw);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user