feat: add server-side ETL pipeline, revert client to NocoDB reads

ETL Pipeline (server):
- POST /api/etl/sync?mode=full|incremental — fetches ERP, aggregates, writes NocoDB
- nocodbClient.ts: table discovery, paginated delete/insert
- etlSync.ts: orchestrates fetch → aggregate → upsert
- museumMapping.ts moved from client to server
- Auth via ETL_SECRET bearer token

Client:
- dataService.ts reverts to reading NocoDB DailySales table
- Paginated fetch via fetchNocoDBTable (handles >1000 rows)
- Suspicious data check: prefers cache if NocoDB returns <10 rows
- Deleted erpService.ts and client-side museumMapping.ts

First full sync: 391K transactions → 5,760 daily records in 108s.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
fahed
2026-03-31 13:25:50 +03:00
parent 9c0ffa5721
commit 1f1e0756d0
12 changed files with 455 additions and 141 deletions

View File

@@ -7,11 +7,10 @@ ERP_API_CODE=your-api-function-key
ERP_USERNAME=your-username
ERP_PASSWORD=your-password
# Salla OAuth Credentials (from Salla Partners dashboard)
SALLA_CLIENT_ID=your_client_id_here
SALLA_CLIENT_SECRET=your_client_secret_here
SALLA_REDIRECT_URI=http://localhost:3001/auth/callback
# NocoDB (for ETL writes)
NOCODB_URL=http://localhost:8090
NOCODB_TOKEN=your-token
NOCODB_BASE_ID=your-base-id
# After OAuth, these will be populated automatically
# SALLA_ACCESS_TOKEN=
# SALLA_REFRESH_TOKEN=
# ETL sync secret (for cron auth)
ETL_SECRET=your-secret-here