Schema (packages/database/prisma/schema.prisma): - Add SenaeCategory, B2BRequestStatus, NotificationChannel enums - Add Package fields: lengthCm, widthCm, heightCm, hasDiscrepancy, photos[], senaeCategory, senaeAuthNumber, senaeDeclarationId - Add userId field to PreAlert - Add RefreshToken model (JWT auth — Fase 1) - Add Tariff model (configurable rates: pricePerLb, insurancePct, etc.) - Add B2BRequest model (heavy cargo imports — doc §13) - Add Notification model (multi-channel: email, whatsapp, sms, push — doc §16) - Add userAgent to AuditLog API (apps/api): - Add CalculatorModule: calculates SENAE cost breakdown (flete, seguro, FODINFA, arancel, IVA) per formulas in doc §15 - Add TrackingModule: public GET /api/tracking/:id endpoint (doc §07) - Register both modules in AppModule - Add Jest config + test scripts (test, test:watch, test:cov, test:ci) Tests (80 tests, 97.45% coverage): - calculator.util.spec.ts: 35 tests — SENAE formulas, volumetric weight, 4x4 regime, tariff rates, error validation, breakdown - tracking-id.util.spec.ts: 13 tests — format, uniqueness, validation - suite-code.util.spec.ts: 13 tests — generation, parsing, address builder - health.controller.spec.ts: 5 tests — ok/degraded/timestamp - calculator.spec.ts: 8 tests — controller + service unit tests - tracking.controller.spec.ts: 9 tests — public search, 404, no sensitive data Web (apps/web): - page.tsx: Full landing page matching documentation (Hero, Services, 8 Modules, Tracking states, SENAE calculator preview, 6 Roles, Companies) - /calculadora: SENAE categories + API usage guide - /tracking: Tracking ID format + 11 states reference Seed (packages/database/prisma/seed.ts): - Creates all 6 roles (SUPER_ADMIN, ADMIN_EMPRESA, OPERADOR_BODEGA, AGENTE_ADUANERO, CLIENTE, SOPORTE) - Assigns Suite EC-00001 to demo client - Creates demo Package EC-20260506-000001 with status history - Creates demo PreAlert and B2BRequest .env.example: Added all 9 integrations from doc §18: Amazon SP-API, SENAE WebService, Stripe/PayPhone, WhatsApp Business API, SendGrid/SES, SMS/Twilio, FedEx/DHL/UPS couriers, S3/MinIO, Sentry migration.sql: Updated to reflect all new models and fields turbo.json + package.json: Added test, test:cov, test:ci tasks + db:seed script
133 lines
5.2 KiB
Bash
133 lines
5.2 KiB
Bash
# ══════════════════════════════════════════════════════════════
|
|
# Moraworld Imports — Variables de entorno
|
|
# Sincronizado con documentacion.html v1.1
|
|
# ══════════════════════════════════════════════════════════════
|
|
|
|
# ─── Base de datos ───────────────────────────────────────────
|
|
# Opción A — Coolify (PostgreSQL gestionado):
|
|
# DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/NOMBRE_BD?schema=moraworld"
|
|
#
|
|
# Opción B — Local con docker compose:
|
|
DATABASE_URL="postgresql://moraworld:moraworld_dev@localhost:5432/moraworld?schema=public"
|
|
|
|
# ─── Redis (colas de notificaciones, sesiones) ───────────────
|
|
# Opción A — Coolify:
|
|
# REDIS_URL="redis://:PASSWORD@HOST:6379"
|
|
# REDIS_URL="rediss://:PASSWORD@HOST:6380" # si TLS
|
|
#
|
|
# Opción B — Local:
|
|
REDIS_URL="redis://localhost:6379"
|
|
|
|
# ─── API (NestJS) ────────────────────────────────────────────
|
|
API_PORT=3001
|
|
API_URL="http://localhost:3001"
|
|
|
|
# JWT — Autenticación OAuth 2.0 + JWT + MFA (doc §05)
|
|
JWT_SECRET="change-me-in-production-min-32-chars-long-abc123"
|
|
JWT_EXPIRES_IN="15m"
|
|
JWT_REFRESH_EXPIRES_IN="7d"
|
|
|
|
# ─── Web (Next.js) ───────────────────────────────────────────
|
|
WEB_PORT=3000
|
|
NEXT_PUBLIC_API_URL="http://localhost:3001"
|
|
|
|
# ─── CORS (coma separada; en Coolify usar dominio real) ──────
|
|
CORS_ORIGINS="http://localhost:3000"
|
|
|
|
# ─── Moraworld — Bodega NJ (doc §02) ─────────────────────────
|
|
# Dirección: 150 N Day St, City of Orange, NJ 07050, EE.UU.
|
|
WAREHOUSE_ADDRESS_STREET="150 N Day St"
|
|
WAREHOUSE_ADDRESS_CITY="City of Orange"
|
|
WAREHOUSE_ADDRESS_STATE="NJ"
|
|
WAREHOUSE_ADDRESS_ZIP="07050"
|
|
WAREHOUSE_ADDRESS_COUNTRY="US"
|
|
|
|
# ─── Amazon SP-API (doc §14 — registro por enlace) ───────────
|
|
# https://developer-docs.amazon.com/sp-api/docs
|
|
AMAZON_SP_CLIENT_ID=""
|
|
AMAZON_SP_CLIENT_SECRET=""
|
|
AMAZON_SP_REFRESH_TOKEN=""
|
|
AMAZON_SP_MARKETPLACE_ID="ATVPDKIKX0DER" # US marketplace
|
|
|
|
# ─── WebService SENAE (doc §11 — declaración aduanera) ───────
|
|
# SOAP / REST — Portal electrónico aduana Ecuador
|
|
SENAE_ENDPOINT="https://declaraciones.aduana.gob.ec/wsDeclaraciones"
|
|
SENAE_USERNAME=""
|
|
SENAE_PASSWORD=""
|
|
SENAE_CERT_PATH="" # Certificado digital PEM
|
|
SENAE_CERT_PASSPHRASE=""
|
|
|
|
# ─── Pasarela de pagos (doc §09 paso 8 / §18) ────────────────
|
|
# Stripe (internacional)
|
|
STRIPE_SECRET_KEY=""
|
|
STRIPE_WEBHOOK_SECRET=""
|
|
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=""
|
|
|
|
# PayPhone (Ecuador)
|
|
PAYPHONE_APP_ID=""
|
|
PAYPHONE_TOKEN=""
|
|
PAYPHONE_STORE_ID=""
|
|
|
|
# ─── WhatsApp Business API (doc §16 / §18) ───────────────────
|
|
# Notificaciones automáticas + botón flotante de contacto
|
|
WHATSAPP_API_URL="https://graph.facebook.com/v19.0"
|
|
WHATSAPP_PHONE_NUMBER_ID=""
|
|
WHATSAPP_ACCESS_TOKEN=""
|
|
# Número NJ (operaciones) y Cuenca (aduana) — doc §21
|
|
WHATSAPP_NJ_NUMBER="+15550000001"
|
|
WHATSAPP_CUENCA_NUMBER="+5939900000001"
|
|
|
|
# ─── Email (doc §16) ─────────────────────────────────────────
|
|
# SendGrid
|
|
SENDGRID_API_KEY=""
|
|
EMAIL_FROM="noreply@moraworldimports.com"
|
|
|
|
# AWS SES (alternativa)
|
|
# AWS_SES_REGION="us-east-1"
|
|
# AWS_SES_ACCESS_KEY=""
|
|
# AWS_SES_SECRET_KEY=""
|
|
|
|
# ─── SMS Gateway (doc §16) ───────────────────────────────────
|
|
SMS_PROVIDER="twilio" # twilio | vonage
|
|
TWILIO_ACCOUNT_SID=""
|
|
TWILIO_AUTH_TOKEN=""
|
|
TWILIO_PHONE_NUMBER=""
|
|
|
|
# ─── Couriers internacionales (doc §18) ──────────────────────
|
|
# FedEx
|
|
FEDEX_CLIENT_ID=""
|
|
FEDEX_CLIENT_SECRET=""
|
|
FEDEX_ACCOUNT_NUMBER=""
|
|
|
|
# DHL
|
|
DHL_API_KEY=""
|
|
DHL_API_SECRET=""
|
|
|
|
# UPS
|
|
UPS_CLIENT_ID=""
|
|
UPS_CLIENT_SECRET=""
|
|
|
|
# ─── S3 / Almacenamiento de archivos (doc §05) ───────────────
|
|
# Fotos de paquetes, facturas, documentos SENAE
|
|
# AWS S3
|
|
S3_BUCKET="moraworld-files"
|
|
S3_REGION="us-east-1"
|
|
S3_ACCESS_KEY=""
|
|
S3_SECRET_KEY=""
|
|
|
|
# MinIO local (docker-compose — desarrollo):
|
|
# S3_ENDPOINT="http://localhost:9000"
|
|
# S3_BUCKET="moraworld"
|
|
# S3_ACCESS_KEY="minioadmin"
|
|
# S3_SECRET_KEY="minioadmin"
|
|
# S3_REGION="us-east-1"
|
|
# S3_FORCE_PATH_STYLE="true"
|
|
|
|
# ─── SIEM / Monitoreo (doc §05 ISO A.12) ─────────────────────
|
|
# Datadog / New Relic / Sentry
|
|
SENTRY_DSN=""
|
|
# DATADOG_API_KEY=""
|
|
|
|
# ─── Entorno ─────────────────────────────────────────────────
|
|
NODE_ENV="development" # development | staging | production
|