(organizationId: string)
| 55 | |
| 56 | // Authentication |
| 57 | async function getAuthConfig(organizationId: string): Promise<AuthConfig> { |
| 58 | console.log('🔑 Generating authentication token...'); |
| 59 | if (z.uuid().safeParse(organizationId).success) { |
| 60 | console.log(` Organization ID: ${organizationId}`); |
| 61 | const authToken = await getAuthToken(organizationId); |
| 62 | const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'; |
| 63 | console.log(' ✅ Token generated successfully'); |
| 64 | return { authToken, baseUrl, organizationId }; |
| 65 | } else { |
| 66 | const user = await db |
| 67 | .select() |
| 68 | .from(kilocode_users) |
| 69 | .where(eq(kilocode_users.google_user_email, organizationId)) |
| 70 | .limit(1); |
| 71 | if (!user || user.length === 0) { |
| 72 | throw new Error(`User with email ${organizationId} not found`); |
| 73 | } |
| 74 | |
| 75 | console.log(` User Email: ${organizationId}`); |
| 76 | const authToken = generateApiToken(user[0]); |
| 77 | const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'; |
| 78 | console.log(' ✅ Token generated successfully'); |
| 79 | return { authToken, baseUrl, organizationId: null }; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // File operations |
| 84 | function findTypeScriptFiles(dir: string): string[] { |
no test coverage detected