17 lines
451 B
TypeScript
17 lines
451 B
TypeScript
// Универсальная функция для извлечения id из разных форматов входных данных
|
|
export function extractId(input) {
|
|
if (typeof input === 'number' || typeof input === 'string') {
|
|
return input;
|
|
}
|
|
if (input?.id) {
|
|
return input.id;
|
|
}
|
|
if (input?.set?.[0]?.id) {
|
|
return input.set[0].id;
|
|
}
|
|
if (input?.connect?.[0]?.id) {
|
|
return input.connect[0].id;
|
|
}
|
|
return null;
|
|
}
|