import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() async function checkActiveKey() { try { // Найдем организацию Rennel const org = await prisma.organization.findFirst({ where: { name: 'Rennel', type: 'SELLER' }, include: { users: true, apiKeys: { where: { marketplace: 'WILDBERRIES', isActive: true, }, orderBy: { createdAt: 'desc' }, }, }, }) if (!org) { console.log('❌ Организация Rennel не найдена') return } console.log('🏢 ОРГАНИЗАЦИЯ RENNEL:') console.log('- ID:', org.id) console.log('- Пользователей:', org.users.length) console.log('- Активных WB ключей:', org.apiKeys.length) if (org.apiKeys.length > 0) { const activeKey = org.apiKeys[0] // Последний созданный console.log('\n🔑 АКТИВНЫЙ КЛЮЧ (который будет использоваться):') console.log('- ID:', activeKey.id) console.log('- Длина:', activeKey.apiKey?.length) console.log('- Тип:', activeKey.apiKey?.startsWith('eyJ') ? 'Валидный JWT' : 'Тестовый') console.log('- Создан:', activeKey.createdAt.toISOString()) console.log('- Данные валидации:', JSON.stringify(activeKey.validationData, null, 2)) } } catch (error) { console.error('❌ Ошибка:', error) } finally { await prisma.$disconnect() } } checkActiveKey()