Incluye utilidades de ops para CRON_SECRET, login customer Google Ads, sync de seguimiento BPS y probes de conexiones. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { config } from 'dotenv';
|
|
import { resolve } from 'path';
|
|
config({ path: resolve(process.cwd(), '.env.local') });
|
|
|
|
import {
|
|
buildSeguimientoRowsForDoc,
|
|
upsertSeguimientoRows,
|
|
patchSuperhumanIntegration,
|
|
findSeguimientoGoogleDoc,
|
|
} from '../src/lib/superhuman-docs';
|
|
|
|
const BPS = '8bec977a-6032-4759-aa7f-b5042081f450';
|
|
const DOC = '7TGywaNiUY';
|
|
|
|
async function main() {
|
|
const hit = await findSeguimientoGoogleDoc([
|
|
'Seguimiento BPS',
|
|
'Seguimiento Semanal BPS',
|
|
'Seguimiento Blue Parrot School',
|
|
'Seguimiento Semanal Blue Parrot School',
|
|
]);
|
|
console.log('drive hit', hit);
|
|
|
|
const rows = await buildSeguimientoRowsForDoc({
|
|
tenantId: BPS,
|
|
tenantName: 'BPS',
|
|
docId: DOC,
|
|
maxEntries: 120,
|
|
exportBodies: true,
|
|
});
|
|
const gdoc = rows.filter((r) => r.external_id.startsWith('gdoc:'));
|
|
console.log('total', rows.length, 'gdoc days', gdoc.length);
|
|
console.log(
|
|
gdoc.slice(0, 5).map((r) => ({
|
|
title: r.title,
|
|
day: r.occurred_at,
|
|
len: (r.body_md || '').length,
|
|
}))
|
|
);
|
|
const n = await upsertSeguimientoRows(rows);
|
|
await patchSuperhumanIntegration(BPS, {
|
|
status: 'connected',
|
|
external_account_id: DOC,
|
|
label: '01.BLUE PARROT SCHOOL',
|
|
last_sync_at: new Date().toISOString(),
|
|
error_message: null,
|
|
meta: {
|
|
doc_name: '01.BLUE PARROT SCHOOL',
|
|
entries: n,
|
|
gdoc_days: gdoc.length,
|
|
synced_at: new Date().toISOString(),
|
|
},
|
|
});
|
|
console.log('upserted', n);
|
|
}
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|