Download apps/api/src/scripts/copy-wa-config.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/apps/api/src/scripts/copy-wa-config.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/apps/api/src/scripts/copy-wa-config.ts
-
curl -L -o copy-wa-config.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/apps/api/src/scripts/copy-wa-config.ts
1.79 kB
| import { PrismaClient } from '@repo/database'; | |
| const prisma = new PrismaClient(); | |
| const XAMLE_ID = 'default-org-id'; | |
| async function main() { | |
| // Lister toutes les orgs pour trouver "xamlé admin" | |
| const orgs = await prisma.organization.findMany({ | |
| select: { id: true, name: true, wabaId: true, systemUserToken: true } | |
| }); | |
| console.log('\n[ORGS]'); | |
| for (const o of orgs) { | |
| console.log(` ${o.name.padEnd(30)} id=${o.id} wabaId=${o.wabaId ?? 'null'} token=${o.systemUserToken ? 'OUI' : 'NON'}`); | |
| } | |
| // Source : xamlé global | |
| const source = await prisma.organization.findUnique({ | |
| where: { id: XAMLE_ID }, | |
| select: { systemUserToken: true, openAiApiKey: true, googleAiApiKey: true } | |
| }); | |
| if (!source?.systemUserToken) { | |
| console.error('[ERROR] Token source introuvable.'); | |
| process.exit(1); | |
| } | |
| // Trouver xamlé admin (nom approximatif) | |
| const target = orgs.find(o => | |
| o.id !== XAMLE_ID && o.name.toLowerCase().includes('admin') | |
| ); | |
| if (!target) { | |
| console.log('\n[INFO] Aucune org avec "admin" dans le nom trouvée — liste ci-dessus pour identifier manuellement.'); | |
| process.exit(0); | |
| } | |
| console.log(`\n[TARGET] "${target.name}" (${target.id})`); | |
| // Copier token + clés AI uniquement — pas de wabaId | |
| await prisma.organization.update({ | |
| where: { id: target.id }, | |
| data: { | |
| systemUserToken: source.systemUserToken, | |
| openAiApiKey: source.openAiApiKey, | |
| googleAiApiKey: source.googleAiApiKey, | |
| } | |
| }); | |
| console.log('[OK] systemUserToken + clés AI copiés (wabaId non touché)'); | |
| } | |
| main() | |
| .catch(e => { console.error(e); process.exit(1); }) | |
| .finally(() => prisma.$disconnect()); | |