elevenlabs-webhook-nodejs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +27 -0
- package/.dockerignore +6 -0
- package/.env.example +43 -0
- package/BEFORE-PRODUCTION.md +32 -0
- package/Dockerfile +23 -0
- package/SYSTEM_OVERVIEW.md +942 -0
- package/SYSTEM_STATUS.md +332 -0
- package/backup_script/main.py +146 -0
- package/baileys/.dockerignore +7 -0
- package/baileys/Dockerfile +13 -0
- package/baileys/README.md +412 -0
- package/baileys/index.js +499 -0
- package/baileys/package-lock.json +2532 -0
- package/baileys/package.json +25 -0
- package/baileys/server.js +96 -0
- package/baileys/src/config.js +55 -0
- package/baileys/src/middleware/api-key.js +16 -0
- package/baileys/src/routes/accounts.js +51 -0
- package/baileys/src/routes/chats.js +103 -0
- package/baileys/src/routes/webhooks.js +34 -0
- package/baileys/src/services/account-store.js +259 -0
- package/baileys/src/services/webhook-dispatcher.js +161 -0
- package/baileys/src/services/worker-manager.js +597 -0
- package/baileys/src/utils/jid.js +79 -0
- package/baileys/src/utils/logger.js +16 -0
- package/baileys/src/utils/use-mongodb-auth-state.js +122 -0
- package/baileys/worker.js +721 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +84 -0
- package/dist/app.js.map +1 -0
- package/dist/config/agentPrompts.json +19 -0
- package/dist/config/database.d.ts +1 -0
- package/dist/config/database.js +26 -0
- package/dist/config/database.js.map +1 -0
- package/dist/config/env.d.ts +41 -0
- package/dist/config/env.js +81 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +73 -0
- package/dist/config/index.js.map +1 -0
- package/dist/controllers/webhook.controller.d.ts +10 -0
- package/dist/controllers/webhook.controller.js +128 -0
- package/dist/controllers/webhook.controller.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +13 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/hooks/webhookValidator.d.ts +2 -0
- package/dist/hooks/webhookValidator.js +47 -0
- package/dist/hooks/webhookValidator.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/001_session-architecture.d.ts +3 -0
- package/dist/migrations/001_session-architecture.js +119 -0
- package/dist/migrations/001_session-architecture.js.map +1 -0
- package/dist/migrations/002_agent-ref.d.ts +3 -0
- package/dist/migrations/002_agent-ref.js +55 -0
- package/dist/migrations/002_agent-ref.js.map +1 -0
- package/dist/migrations/003_shift-schedule.d.ts +3 -0
- package/dist/migrations/003_shift-schedule.js +48 -0
- package/dist/migrations/003_shift-schedule.js.map +1 -0
- package/dist/migrations/004_invert-shift-to-clinic-hours.d.ts +3 -0
- package/dist/migrations/004_invert-shift-to-clinic-hours.js +27 -0
- package/dist/migrations/004_invert-shift-to-clinic-hours.js.map +1 -0
- package/dist/migrations/005_composite-baileys-chat-ids.d.ts +3 -0
- package/dist/migrations/005_composite-baileys-chat-ids.js +47 -0
- package/dist/migrations/005_composite-baileys-chat-ids.js.map +1 -0
- package/dist/migrations/migration.model.d.ts +18 -0
- package/dist/migrations/migration.model.js +45 -0
- package/dist/migrations/migration.model.js.map +1 -0
- package/dist/migrations/migration.routes.d.ts +2 -0
- package/dist/migrations/migration.routes.js +37 -0
- package/dist/migrations/migration.routes.js.map +1 -0
- package/dist/migrations/migration.runner.d.ts +19 -0
- package/dist/migrations/migration.runner.js +74 -0
- package/dist/migrations/migration.runner.js.map +1 -0
- package/dist/models/ConversationClaim.d.ts +13 -0
- package/dist/models/ConversationClaim.js +44 -0
- package/dist/models/ConversationClaim.js.map +1 -0
- package/dist/models/ConversationEvaluation.d.ts +23 -0
- package/dist/models/ConversationEvaluation.js +92 -0
- package/dist/models/ConversationEvaluation.js.map +1 -0
- package/dist/models/Summary.d.ts +37 -0
- package/dist/models/Summary.js +78 -0
- package/dist/models/Summary.js.map +1 -0
- package/dist/models/Transcription.d.ts +34 -0
- package/dist/models/Transcription.js +71 -0
- package/dist/models/Transcription.js.map +1 -0
- package/dist/models/WhatsAppRecipient.d.ts +23 -0
- package/dist/models/WhatsAppRecipient.js +53 -0
- package/dist/models/WhatsAppRecipient.js.map +1 -0
- package/dist/modules/admin/admin.routes.d.ts +2 -0
- package/dist/modules/admin/admin.routes.js +1966 -0
- package/dist/modules/admin/admin.routes.js.map +1 -0
- package/dist/modules/admin/elevenlabs-test-chat.routes.d.ts +2 -0
- package/dist/modules/admin/elevenlabs-test-chat.routes.js +158 -0
- package/dist/modules/admin/elevenlabs-test-chat.routes.js.map +1 -0
- package/dist/modules/admin/whatsapp-test-chat.routes.d.ts +2 -0
- package/dist/modules/admin/whatsapp-test-chat.routes.js +204 -0
- package/dist/modules/admin/whatsapp-test-chat.routes.js.map +1 -0
- package/dist/modules/agents/agent.model.d.ts +38 -0
- package/dist/modules/agents/agent.model.js +92 -0
- package/dist/modules/agents/agent.model.js.map +1 -0
- package/dist/modules/agents/agent.routes.d.ts +2 -0
- package/dist/modules/agents/agent.routes.js +61 -0
- package/dist/modules/agents/agent.routes.js.map +1 -0
- package/dist/modules/appointment-validation/appointment-validation.model.d.ts +76 -0
- package/dist/modules/appointment-validation/appointment-validation.model.js +118 -0
- package/dist/modules/appointment-validation/appointment-validation.model.js.map +1 -0
- package/dist/modules/appointment-validation/appointment-validation.routes.d.ts +2 -0
- package/dist/modules/appointment-validation/appointment-validation.routes.js +202 -0
- package/dist/modules/appointment-validation/appointment-validation.routes.js.map +1 -0
- package/dist/modules/appointment-validation/appointment-validation.service.d.ts +53 -0
- package/dist/modules/appointment-validation/appointment-validation.service.js +827 -0
- package/dist/modules/appointment-validation/appointment-validation.service.js.map +1 -0
- package/dist/modules/auth/auth.model.d.ts +17 -0
- package/dist/modules/auth/auth.model.js +64 -0
- package/dist/modules/auth/auth.model.js.map +1 -0
- package/dist/modules/auth/auth.routes.d.ts +2 -0
- package/dist/modules/auth/auth.routes.js +202 -0
- package/dist/modules/auth/auth.routes.js.map +1 -0
- package/dist/modules/auth/auth.service.d.ts +28 -0
- package/dist/modules/auth/auth.service.js +183 -0
- package/dist/modules/auth/auth.service.js.map +1 -0
- package/dist/modules/auth/refresh-token.model.d.ts +13 -0
- package/dist/modules/auth/refresh-token.model.js +52 -0
- package/dist/modules/auth/refresh-token.model.js.map +1 -0
- package/dist/modules/billing/billing-alert.model.d.ts +16 -0
- package/dist/modules/billing/billing-alert.model.js +47 -0
- package/dist/modules/billing/billing-alert.model.js.map +1 -0
- package/dist/modules/billing/billing-period-snapshot.model.d.ts +35 -0
- package/dist/modules/billing/billing-period-snapshot.model.js +68 -0
- package/dist/modules/billing/billing-period-snapshot.model.js.map +1 -0
- package/dist/modules/billing/billing.model.d.ts +18 -0
- package/dist/modules/billing/billing.model.js +62 -0
- package/dist/modules/billing/billing.model.js.map +1 -0
- package/dist/modules/billing/billing.routes.d.ts +2 -0
- package/dist/modules/billing/billing.routes.js +63 -0
- package/dist/modules/billing/billing.routes.js.map +1 -0
- package/dist/modules/billing/billing.service.d.ts +69 -0
- package/dist/modules/billing/billing.service.js +498 -0
- package/dist/modules/billing/billing.service.js.map +1 -0
- package/dist/modules/billing/payment.model.d.ts +24 -0
- package/dist/modules/billing/payment.model.js +57 -0
- package/dist/modules/billing/payment.model.js.map +1 -0
- package/dist/modules/calls/call.model.d.ts +41 -0
- package/dist/modules/calls/call.model.js +97 -0
- package/dist/modules/calls/call.model.js.map +1 -0
- package/dist/modules/calls/call.routes.d.ts +2 -0
- package/dist/modules/calls/call.routes.js +103 -0
- package/dist/modules/calls/call.routes.js.map +1 -0
- package/dist/modules/campaigns/campaign.model.d.ts +45 -0
- package/dist/modules/campaigns/campaign.model.js +98 -0
- package/dist/modules/campaigns/campaign.model.js.map +1 -0
- package/dist/modules/campaigns/campaign.routes.d.ts +2 -0
- package/dist/modules/campaigns/campaign.routes.js +323 -0
- package/dist/modules/campaigns/campaign.routes.js.map +1 -0
- package/dist/modules/campaigns/campaign.service.d.ts +11 -0
- package/dist/modules/campaigns/campaign.service.js +86 -0
- package/dist/modules/campaigns/campaign.service.js.map +1 -0
- package/dist/modules/google-calendar/google-calendar.routes.d.ts +2 -0
- package/dist/modules/google-calendar/google-calendar.routes.js +32 -0
- package/dist/modules/google-calendar/google-calendar.routes.js.map +1 -0
- package/dist/modules/inbound-call/inbound-call-config.model.d.ts +20 -0
- package/dist/modules/inbound-call/inbound-call-config.model.js +68 -0
- package/dist/modules/inbound-call/inbound-call-config.model.js.map +1 -0
- package/dist/modules/inbound-call/inbound-call.routes.d.ts +2 -0
- package/dist/modules/inbound-call/inbound-call.routes.js +243 -0
- package/dist/modules/inbound-call/inbound-call.routes.js.map +1 -0
- package/dist/modules/leads/lead.model.d.ts +24 -0
- package/dist/modules/leads/lead.model.js +54 -0
- package/dist/modules/leads/lead.model.js.map +1 -0
- package/dist/modules/leads/lead.routes.d.ts +2 -0
- package/dist/modules/leads/lead.routes.js +201 -0
- package/dist/modules/leads/lead.routes.js.map +1 -0
- package/dist/modules/plans/plan.model.d.ts +25 -0
- package/dist/modules/plans/plan.model.js +59 -0
- package/dist/modules/plans/plan.model.js.map +1 -0
- package/dist/modules/surveys/survey.model.d.ts +30 -0
- package/dist/modules/surveys/survey.model.js +75 -0
- package/dist/modules/surveys/survey.model.js.map +1 -0
- package/dist/modules/surveys/survey.routes.d.ts +2 -0
- package/dist/modules/surveys/survey.routes.js +153 -0
- package/dist/modules/surveys/survey.routes.js.map +1 -0
- package/dist/modules/tenants/tenant.model.d.ts +86 -0
- package/dist/modules/tenants/tenant.model.js +127 -0
- package/dist/modules/tenants/tenant.model.js.map +1 -0
- package/dist/modules/tenants/tenant.routes.d.ts +2 -0
- package/dist/modules/tenants/tenant.routes.js +65 -0
- package/dist/modules/tenants/tenant.routes.js.map +1 -0
- package/dist/modules/users/user.routes.d.ts +2 -0
- package/dist/modules/users/user.routes.js +106 -0
- package/dist/modules/users/user.routes.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs-tool.routes.d.ts +20 -0
- package/dist/modules/webhooks/elevenlabs-tool.routes.js +85 -0
- package/dist/modules/webhooks/elevenlabs-tool.routes.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs-tool.service.d.ts +11 -0
- package/dist/modules/webhooks/elevenlabs-tool.service.js +360 -0
- package/dist/modules/webhooks/elevenlabs-tool.service.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs.routes.d.ts +2 -0
- package/dist/modules/webhooks/elevenlabs.routes.js +34 -0
- package/dist/modules/webhooks/elevenlabs.routes.js.map +1 -0
- package/dist/modules/webhooks/elevenlabs.service.d.ts +6 -0
- package/dist/modules/webhooks/elevenlabs.service.js +512 -0
- package/dist/modules/webhooks/elevenlabs.service.js.map +1 -0
- package/dist/modules/webhooks/unipile.routes.d.ts +2 -0
- package/dist/modules/webhooks/unipile.routes.js +780 -0
- package/dist/modules/webhooks/unipile.routes.js.map +1 -0
- package/dist/modules/whatsapp/appointment.model.d.ts +27 -0
- package/dist/modules/whatsapp/appointment.model.js +58 -0
- package/dist/modules/whatsapp/appointment.model.js.map +1 -0
- package/dist/modules/whatsapp/operator-request.model.d.ts +29 -0
- package/dist/modules/whatsapp/operator-request.model.js +65 -0
- package/dist/modules/whatsapp/operator-request.model.js.map +1 -0
- package/dist/modules/whatsapp/stt-usage.model.d.ts +16 -0
- package/dist/modules/whatsapp/stt-usage.model.js +53 -0
- package/dist/modules/whatsapp/stt-usage.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-chat.model.d.ts +23 -0
- package/dist/modules/whatsapp/whatsapp-chat.model.js +55 -0
- package/dist/modules/whatsapp/whatsapp-chat.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-contact-profile.model.d.ts +23 -0
- package/dist/modules/whatsapp/whatsapp-contact-profile.model.js +54 -0
- package/dist/modules/whatsapp/whatsapp-contact-profile.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-message.model.d.ts +30 -0
- package/dist/modules/whatsapp/whatsapp-message.model.js +52 -0
- package/dist/modules/whatsapp/whatsapp-message.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp-session.model.d.ts +33 -0
- package/dist/modules/whatsapp/whatsapp-session.model.js +65 -0
- package/dist/modules/whatsapp/whatsapp-session.model.js.map +1 -0
- package/dist/modules/whatsapp/whatsapp.routes.d.ts +2 -0
- package/dist/modules/whatsapp/whatsapp.routes.js +1237 -0
- package/dist/modules/whatsapp/whatsapp.routes.js.map +1 -0
- package/dist/plugins/cors.d.ts +3 -0
- package/dist/plugins/cors.js +11 -0
- package/dist/plugins/cors.js.map +1 -0
- package/dist/plugins/jwt.d.ts +3 -0
- package/dist/plugins/jwt.js +22 -0
- package/dist/plugins/jwt.js.map +1 -0
- package/dist/plugins/rawBody.d.ts +3 -0
- package/dist/plugins/rawBody.js +16 -0
- package/dist/plugins/rawBody.js.map +1 -0
- package/dist/plugins/rbac.d.ts +5 -0
- package/dist/plugins/rbac.js +29 -0
- package/dist/plugins/rbac.js.map +1 -0
- package/dist/routes/admin.routes.d.ts +2 -0
- package/dist/routes/admin.routes.js +169 -0
- package/dist/routes/admin.routes.js.map +1 -0
- package/dist/routes/health.routes.d.ts +2 -0
- package/dist/routes/health.routes.js +16 -0
- package/dist/routes/health.routes.js.map +1 -0
- package/dist/routes/webhook.routes.d.ts +2 -0
- package/dist/routes/webhook.routes.js +17 -0
- package/dist/routes/webhook.routes.js.map +1 -0
- package/dist/services/ai/base.ai.d.ts +19 -0
- package/dist/services/ai/base.ai.js +120 -0
- package/dist/services/ai/base.ai.js.map +1 -0
- package/dist/services/ai/gemini.service.d.ts +11 -0
- package/dist/services/ai/gemini.service.js +43 -0
- package/dist/services/ai/gemini.service.js.map +1 -0
- package/dist/services/ai/index.d.ts +2 -0
- package/dist/services/ai/index.js +26 -0
- package/dist/services/ai/index.js.map +1 -0
- package/dist/services/ai/openai.service.d.ts +11 -0
- package/dist/services/ai/openai.service.js +50 -0
- package/dist/services/ai/openai.service.js.map +1 -0
- package/dist/services/elevenlabs.service.d.ts +52 -0
- package/dist/services/elevenlabs.service.js +447 -0
- package/dist/services/elevenlabs.service.js.map +1 -0
- package/dist/services/google-calendar.service.d.ts +60 -0
- package/dist/services/google-calendar.service.js +494 -0
- package/dist/services/google-calendar.service.js.map +1 -0
- package/dist/services/inbound-call-schedule.service.d.ts +11 -0
- package/dist/services/inbound-call-schedule.service.js +162 -0
- package/dist/services/inbound-call-schedule.service.js.map +1 -0
- package/dist/services/netgsm.service.d.ts +41 -0
- package/dist/services/netgsm.service.js +89 -0
- package/dist/services/netgsm.service.js.map +1 -0
- package/dist/services/unipile.service.d.ts +41 -0
- package/dist/services/unipile.service.js +149 -0
- package/dist/services/unipile.service.js.map +1 -0
- package/dist/services/whatsapp-agent.service.d.ts +139 -0
- package/dist/services/whatsapp-agent.service.js +2055 -0
- package/dist/services/whatsapp-agent.service.js.map +1 -0
- package/dist/services/whatsapp.service.d.ts +26 -0
- package/dist/services/whatsapp.service.js +206 -0
- package/dist/services/whatsapp.service.js.map +1 -0
- package/dist/templates/index.d.ts +39 -0
- package/dist/templates/index.js +35 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/receptionist.d.ts +2 -0
- package/dist/templates/receptionist.js +39 -0
- package/dist/templates/receptionist.js.map +1 -0
- package/dist/templates/survey.d.ts +2 -0
- package/dist/templates/survey.js +41 -0
- package/dist/templates/survey.js.map +1 -0
- package/dist/types/index.d.ts +173 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.js +105 -0
- package/dist/utils/logger.js.map +1 -0
- package/docker-compose.nestjs.yml +89 -0
- package/docker-compose.yml +78 -0
- package/docs/AI_AGENT_ENHANCEMENT_PLAN.md +164 -0
- package/docs/API.md +1193 -0
- package/docs/API_ENDPOINTS.md +344 -0
- package/docs/ARCHITECTURE.md +305 -0
- package/docs/AUTH_API.md +252 -0
- package/docs/BILLING_SMS_ALERTS.md +94 -0
- package/docs/CHAT_ASSIGNMENT_SYSTEM.md +118 -0
- package/docs/CLIENT_TOOLS_AND_FEATURES.md +337 -0
- package/docs/ELEVENLABS_WEBHOOK_TOOLS.md +644 -0
- package/docs/FRONTEND_CHECKLIST.md +227 -0
- package/docs/IMPLEMENTATION_STATUS.md +470 -0
- package/docs/MIGRATION_GUIDE.md +96 -0
- package/docs/MISSINGS_REPORT.md +507 -0
- package/docs/NESTJS_MIGRATION_REFERENCE.md +5136 -0
- package/docs/PROJECT_DESCRIPTION.md +1038 -0
- package/docs/SCALING.md +148 -0
- package/docs/SESSION_SUMMARY_2026_03_17.md +135 -0
- package/docs/WHATSAPP_AGENT.md +1086 -0
- package/docs/architecture/00-SYSTEM-OVERVIEW.md +318 -0
- package/docs/architecture/01-DATABASE-SCHEMA.md +2564 -0
- package/docs/architecture/02-AUTHENTICATION.md +1040 -0
- package/docs/architecture/03-MULTI-CLINIC.md +742 -0
- package/docs/architecture/04-WHATSAPP-AGENT.md +608 -0
- package/docs/architecture/05-OPERATOR-WORKFLOW.md +444 -0
- package/docs/architecture/06-BAILEYS-MICROSERVICE.md +616 -0
- package/docs/architecture/07-APPOINTMENTS.md +849 -0
- package/docs/architecture/08-VOICE-CALLS.md +470 -0
- package/docs/architecture/09-OUTBOUND-CAMPAIGNS.md +542 -0
- package/docs/architecture/10-CLIENT-TOOLS.md +665 -0
- package/docs/architecture/11-BILLING.md +458 -0
- package/docs/architecture/12-SECURITY.md +216 -0
- package/docs/architecture/13-LOGGING-AUDIT.md +549 -0
- package/docs/architecture/14-META-BUSINESS-API.md +454 -0
- package/docs/architecture/15-AI-MODULE.md +479 -0
- package/docs/architecture/16-BACKGROUND-JOBS.md +469 -0
- package/docs/architecture/17-REALTIME-LIVECHAT.md +447 -0
- package/docs/architecture/18-FILE-STORAGE.md +410 -0
- package/docs/architecture/19-PATIENTS.md +1034 -0
- package/docs/architecture/20-TREATMENTS-AND-PLANS.md +774 -0
- package/docs/architecture/21-BEFORE-AFTER-PHOTOS.md +519 -0
- package/docs/database.md +456 -0
- package/docs/ornek-randevu-onay.csv +3 -0
- package/ecosystem.config.js +16 -0
- package/elevenlabs-convai-api-reference.md +1171 -0
- package/frontend/.dockerignore +2 -0
- package/frontend/Dockerfile +24 -0
- package/frontend/README.md +75 -0
- package/frontend/components.json +25 -0
- package/frontend/eslint.config.js +23 -0
- package/frontend/index.html +13 -0
- package/frontend/nginx.conf +37 -0
- package/frontend/package-lock.json +8709 -0
- package/frontend/package.json +71 -0
- package/frontend/public/favicon.svg +1 -0
- package/frontend/public/icons.svg +24 -0
- package/frontend/src/App.tsx +125 -0
- package/frontend/src/components/error-boundary.tsx +50 -0
- package/frontend/src/components/shared/activity-timeline.tsx +66 -0
- package/frontend/src/components/shared/appointment-calendar.css +80 -0
- package/frontend/src/components/shared/appointment-calendar.tsx +245 -0
- package/frontend/src/components/shared/chat-bubble.tsx +72 -0
- package/frontend/src/components/shared/combobox.tsx +119 -0
- package/frontend/src/components/shared/confirm-dialog.tsx +57 -0
- package/frontend/src/components/shared/data-table-pagination.tsx +97 -0
- package/frontend/src/components/shared/data-table-toolbar.tsx +39 -0
- package/frontend/src/components/shared/empty-state.tsx +27 -0
- package/frontend/src/components/shared/file-upload.tsx +140 -0
- package/frontend/src/components/shared/index.ts +20 -0
- package/frontend/src/components/shared/language-switcher.tsx +29 -0
- package/frontend/src/components/shared/notification-dropdown.tsx +115 -0
- package/frontend/src/components/shared/page-header.tsx +23 -0
- package/frontend/src/components/shared/stat-card.tsx +37 -0
- package/frontend/src/components/shared/status-badge.tsx +70 -0
- package/frontend/src/components/shared/status-dot.tsx +43 -0
- package/frontend/src/components/ui/alert-dialog.tsx +187 -0
- package/frontend/src/components/ui/alert.tsx +76 -0
- package/frontend/src/components/ui/avatar.tsx +109 -0
- package/frontend/src/components/ui/badge.tsx +52 -0
- package/frontend/src/components/ui/breadcrumb.tsx +125 -0
- package/frontend/src/components/ui/button.tsx +60 -0
- package/frontend/src/components/ui/calendar.tsx +219 -0
- package/frontend/src/components/ui/card.tsx +103 -0
- package/frontend/src/components/ui/chart.tsx +371 -0
- package/frontend/src/components/ui/checkbox.tsx +29 -0
- package/frontend/src/components/ui/collapsible.tsx +19 -0
- package/frontend/src/components/ui/command.tsx +194 -0
- package/frontend/src/components/ui/dialog.tsx +158 -0
- package/frontend/src/components/ui/dropdown-menu.tsx +268 -0
- package/frontend/src/components/ui/input-group.tsx +156 -0
- package/frontend/src/components/ui/input.tsx +20 -0
- package/frontend/src/components/ui/label.tsx +20 -0
- package/frontend/src/components/ui/pagination.tsx +130 -0
- package/frontend/src/components/ui/popover.tsx +90 -0
- package/frontend/src/components/ui/progress.tsx +83 -0
- package/frontend/src/components/ui/radio-group.tsx +36 -0
- package/frontend/src/components/ui/scroll-area.tsx +54 -0
- package/frontend/src/components/ui/select.tsx +199 -0
- package/frontend/src/components/ui/separator.tsx +23 -0
- package/frontend/src/components/ui/sheet.tsx +138 -0
- package/frontend/src/components/ui/sidebar.tsx +723 -0
- package/frontend/src/components/ui/skeleton.tsx +13 -0
- package/frontend/src/components/ui/sonner.tsx +47 -0
- package/frontend/src/components/ui/switch.tsx +30 -0
- package/frontend/src/components/ui/table.tsx +114 -0
- package/frontend/src/components/ui/tabs.tsx +82 -0
- package/frontend/src/components/ui/textarea.tsx +18 -0
- package/frontend/src/components/ui/toggle-group.tsx +89 -0
- package/frontend/src/components/ui/toggle.tsx +43 -0
- package/frontend/src/components/ui/tooltip.tsx +64 -0
- package/frontend/src/hooks/use-mobile.ts +19 -0
- package/frontend/src/i18n/index.ts +20 -0
- package/frontend/src/i18n/locales/en.json +786 -0
- package/frontend/src/i18n/locales/tr.json +786 -0
- package/frontend/src/index.css +134 -0
- package/frontend/src/layouts/admin-layout.tsx +111 -0
- package/frontend/src/layouts/app-header.tsx +130 -0
- package/frontend/src/layouts/app-layout.tsx +19 -0
- package/frontend/src/layouts/app-sidebar.tsx +212 -0
- package/frontend/src/layouts/auth-guard.tsx +31 -0
- package/frontend/src/layouts/mobile-sidebar.tsx +120 -0
- package/frontend/src/lib/api.ts +68 -0
- package/frontend/src/lib/hooks/use-appointments.ts +224 -0
- package/frontend/src/lib/hooks/use-availability-blocks.ts +83 -0
- package/frontend/src/lib/hooks/use-chats.ts +236 -0
- package/frontend/src/lib/hooks/use-clinic-detail.ts +171 -0
- package/frontend/src/lib/hooks/use-clinics.ts +37 -0
- package/frontend/src/lib/hooks/use-doctor-calendar.ts +80 -0
- package/frontend/src/lib/hooks/use-examinations.ts +89 -0
- package/frontend/src/lib/hooks/use-medical-history.ts +52 -0
- package/frontend/src/lib/hooks/use-patients.ts +296 -0
- package/frontend/src/lib/hooks/use-photo-sets.ts +118 -0
- package/frontend/src/lib/hooks/use-treatment-plans.ts +152 -0
- package/frontend/src/lib/hooks/use-treatments.ts +125 -0
- package/frontend/src/lib/hooks/use-users.ts +172 -0
- package/frontend/src/lib/utils.ts +6 -0
- package/frontend/src/main.tsx +17 -0
- package/frontend/src/pages/admin/agents/detail.tsx +774 -0
- package/frontend/src/pages/admin/agents/import.tsx +280 -0
- package/frontend/src/pages/admin/agents/index.tsx +245 -0
- package/frontend/src/pages/admin/ai-playground.tsx +543 -0
- package/frontend/src/pages/appointments/create-appointment-dialog.tsx +390 -0
- package/frontend/src/pages/appointments/index.tsx +860 -0
- package/frontend/src/pages/audit/index.tsx +24 -0
- package/frontend/src/pages/auth/login.tsx +194 -0
- package/frontend/src/pages/billing/index.tsx +24 -0
- package/frontend/src/pages/calendar/index.tsx +704 -0
- package/frontend/src/pages/calendar-connections/index.tsx +295 -0
- package/frontend/src/pages/calls/index.tsx +24 -0
- package/frontend/src/pages/campaigns/index.tsx +24 -0
- package/frontend/src/pages/chats/index.tsx +981 -0
- package/frontend/src/pages/clinics/index.tsx +224 -0
- package/frontend/src/pages/clinics/settings.tsx +412 -0
- package/frontend/src/pages/components-showcase.tsx +773 -0
- package/frontend/src/pages/connections/index.tsx +328 -0
- package/frontend/src/pages/dashboard.tsx +50 -0
- package/frontend/src/pages/leads/index.tsx +24 -0
- package/frontend/src/pages/my-schedule/index.tsx +496 -0
- package/frontend/src/pages/patients/create-patient-dialog.tsx +358 -0
- package/frontend/src/pages/patients/detail.tsx +1195 -0
- package/frontend/src/pages/patients/edit-patient-dialog.tsx +387 -0
- package/frontend/src/pages/patients/examinations-tab.tsx +460 -0
- package/frontend/src/pages/patients/index.tsx +381 -0
- package/frontend/src/pages/patients/medical-history-dialog.tsx +207 -0
- package/frontend/src/pages/patients/photo-sets-tab.tsx +616 -0
- package/frontend/src/pages/patients/timeline-tab.tsx +164 -0
- package/frontend/src/pages/patients/treatment-plans-tab.tsx +598 -0
- package/frontend/src/pages/phone-numbers/detail.tsx +427 -0
- package/frontend/src/pages/phone-numbers/index.tsx +455 -0
- package/frontend/src/pages/platform/index.tsx +454 -0
- package/frontend/src/pages/settings/index.tsx +126 -0
- package/frontend/src/pages/treatments/index.tsx +487 -0
- package/frontend/src/pages/users/doctor-profile.tsx +672 -0
- package/frontend/src/pages/users/edit.tsx +329 -0
- package/frontend/src/pages/users/index.tsx +407 -0
- package/frontend/src/pages/validation/index.tsx +24 -0
- package/frontend/src/stores/auth.store.ts +108 -0
- package/frontend/src/stores/ui.store.ts +41 -0
- package/frontend/tsconfig.app.json +32 -0
- package/frontend/tsconfig.json +13 -0
- package/frontend/tsconfig.node.json +26 -0
- package/frontend/vite.config.ts +29 -0
- package/nestjs/.dockerignore +5 -0
- package/nestjs/.env.docker +64 -0
- package/nestjs/.prettierrc +4 -0
- package/nestjs/Dockerfile +36 -0
- package/nestjs/README.md +98 -0
- package/nestjs/eslint.config.mjs +35 -0
- package/nestjs/nest-cli.json +8 -0
- package/nestjs/package-lock.json +13390 -0
- package/nestjs/package.json +114 -0
- package/nestjs/prisma/migrations/20260409161536_add_message_metadata_fields/migration.sql +1746 -0
- package/nestjs/prisma/migrations/20260410140436_add_agent_ai_fields/migration.sql +36 -0
- package/nestjs/prisma/migrations/20260410175519_add_agent_clinic_assignments/migration.sql +21 -0
- package/nestjs/prisma/migrations/20260412094344_make_agent_tenant_optional/migration.sql +2 -0
- package/nestjs/prisma/migrations/20260412110008_add_admin_chat_sessions/migration.sql +47 -0
- package/nestjs/prisma/migrations/migration_lock.toml +3 -0
- package/nestjs/prisma/schema.prisma +1843 -0
- package/nestjs/prisma/seed.ts +375 -0
- package/nestjs/prisma.config.ts +14 -0
- package/nestjs/src/admin/admin.controller.ts +27 -0
- package/nestjs/src/admin/admin.module.ts +16 -0
- package/nestjs/src/admin/admin.service.ts +91 -0
- package/nestjs/src/admin/ai-chat-session.service.ts +454 -0
- package/nestjs/src/admin/ai-test.controller.ts +191 -0
- package/nestjs/src/admin/superadmin.controller.ts +106 -0
- package/nestjs/src/agents/agents.controller.ts +262 -0
- package/nestjs/src/agents/agents.module.ts +13 -0
- package/nestjs/src/agents/agents.service.ts +733 -0
- package/nestjs/src/agents/dto/create-agent.dto.ts +99 -0
- package/nestjs/src/agents/dto/index.ts +2 -0
- package/nestjs/src/agents/dto/update-agent.dto.ts +148 -0
- package/nestjs/src/app.module.ts +115 -0
- package/nestjs/src/appointment-validation/appointment-validation.controller.ts +194 -0
- package/nestjs/src/appointment-validation/appointment-validation.module.ts +16 -0
- package/nestjs/src/appointment-validation/appointment-validation.service.ts +450 -0
- package/nestjs/src/appointment-validation/dto/create-batch.dto.ts +105 -0
- package/nestjs/src/appointment-validation/dto/index.ts +1 -0
- package/nestjs/src/appointment-validation/processors/validation-dispatch.processor.ts +26 -0
- package/nestjs/src/appointment-validation/processors/validation-sync.processor.ts +23 -0
- package/nestjs/src/appointments/appointments.controller.ts +268 -0
- package/nestjs/src/appointments/appointments.module.ts +13 -0
- package/nestjs/src/appointments/appointments.service.ts +773 -0
- package/nestjs/src/appointments/dto/create-appointment.dto.ts +72 -0
- package/nestjs/src/appointments/dto/index.ts +4 -0
- package/nestjs/src/appointments/dto/query-appointments.dto.ts +60 -0
- package/nestjs/src/appointments/dto/update-appointment.dto.ts +43 -0
- package/nestjs/src/appointments/dto/update-status.dto.ts +18 -0
- package/nestjs/src/appointments/processors/reminder.processor.ts +243 -0
- package/nestjs/src/audit/audit.controller.ts +84 -0
- package/nestjs/src/audit/audit.decorator.ts +20 -0
- package/nestjs/src/audit/audit.interceptor.ts +67 -0
- package/nestjs/src/audit/audit.interfaces.ts +15 -0
- package/nestjs/src/audit/audit.module.ts +12 -0
- package/nestjs/src/audit/audit.service.ts +177 -0
- package/nestjs/src/auth/auth.controller.ts +116 -0
- package/nestjs/src/auth/auth.module.ts +25 -0
- package/nestjs/src/auth/auth.service.ts +612 -0
- package/nestjs/src/auth/dto/change-password.dto.ts +13 -0
- package/nestjs/src/auth/dto/forgot-password.dto.ts +8 -0
- package/nestjs/src/auth/dto/index.ts +6 -0
- package/nestjs/src/auth/dto/login.dto.ts +13 -0
- package/nestjs/src/auth/dto/refresh.dto.ts +8 -0
- package/nestjs/src/auth/dto/register.dto.ts +28 -0
- package/nestjs/src/auth/dto/reset-password.dto.ts +13 -0
- package/nestjs/src/auth/permissions.config.ts +85 -0
- package/nestjs/src/availability-blocks/availability-blocks.controller.ts +83 -0
- package/nestjs/src/availability-blocks/availability-blocks.module.ts +10 -0
- package/nestjs/src/availability-blocks/availability-blocks.service.ts +202 -0
- package/nestjs/src/billing/billing.controller.ts +104 -0
- package/nestjs/src/billing/billing.module.ts +12 -0
- package/nestjs/src/billing/billing.service.ts +398 -0
- package/nestjs/src/billing/dto/index.ts +2 -0
- package/nestjs/src/billing/dto/query-billing.dto.ts +29 -0
- package/nestjs/src/billing/dto/record-payment.dto.ts +60 -0
- package/nestjs/src/billing/processors/alerts.processor.ts +216 -0
- package/nestjs/src/billing/processors/snapshot.processor.ts +181 -0
- package/nestjs/src/calls/calls.controller.ts +92 -0
- package/nestjs/src/calls/calls.module.ts +10 -0
- package/nestjs/src/calls/calls.service.ts +359 -0
- package/nestjs/src/calls/dto/index.ts +1 -0
- package/nestjs/src/calls/dto/query-calls.dto.ts +46 -0
- package/nestjs/src/clinics/clinics.controller.ts +226 -0
- package/nestjs/src/clinics/clinics.module.ts +11 -0
- package/nestjs/src/clinics/clinics.service.ts +203 -0
- package/nestjs/src/clinics/dto/create-clinic.dto.ts +40 -0
- package/nestjs/src/clinics/dto/create-meta-connection.dto.ts +44 -0
- package/nestjs/src/clinics/dto/index.ts +4 -0
- package/nestjs/src/clinics/dto/update-clinic.dto.ts +133 -0
- package/nestjs/src/clinics/dto/update-meta-connection.dto.ts +22 -0
- package/nestjs/src/clinics/meta-connections.service.ts +210 -0
- package/nestjs/src/common/decorators/accessible-clinics.decorator.ts +9 -0
- package/nestjs/src/common/decorators/current-user.decorator.ts +10 -0
- package/nestjs/src/common/decorators/features.decorator.ts +7 -0
- package/nestjs/src/common/decorators/index.ts +4 -0
- package/nestjs/src/common/decorators/permissions.decorator.ts +13 -0
- package/nestjs/src/common/gateways/events.gateway.ts +157 -0
- package/nestjs/src/common/guards/clinic-access.guard.ts +40 -0
- package/nestjs/src/common/guards/features.guard.ts +38 -0
- package/nestjs/src/common/guards/index.ts +5 -0
- package/nestjs/src/common/guards/jwt-auth.guard.ts +54 -0
- package/nestjs/src/common/guards/permissions.guard.ts +50 -0
- package/nestjs/src/common/guards/superadmin.guard.ts +35 -0
- package/nestjs/src/common/interceptors/request-context.interceptor.ts +32 -0
- package/nestjs/src/common/interceptors/superadmin-tenant.interceptor.ts +42 -0
- package/nestjs/src/common/interfaces/jwt-payload.interface.ts +11 -0
- package/nestjs/src/config/config.module.ts +13 -0
- package/nestjs/src/database/database.module.ts +9 -0
- package/nestjs/src/database/prisma.service.ts +20 -0
- package/nestjs/src/database/tenant-context.ts +27 -0
- package/nestjs/src/google-calendar/google-calendar.controller.ts +259 -0
- package/nestjs/src/google-calendar/google-calendar.module.ts +10 -0
- package/nestjs/src/google-calendar/google-calendar.service.ts +811 -0
- package/nestjs/src/integrations/ai/ai.interface.ts +74 -0
- package/nestjs/src/integrations/ai/ai.module.ts +11 -0
- package/nestjs/src/integrations/ai/ai.service.ts +148 -0
- package/nestjs/src/integrations/ai/providers/anthropic.provider.ts +146 -0
- package/nestjs/src/integrations/ai/providers/openai.provider.ts +158 -0
- package/nestjs/src/integrations/elevenlabs/elevenlabs.module.ts +8 -0
- package/nestjs/src/integrations/elevenlabs/elevenlabs.service.ts +226 -0
- package/nestjs/src/integrations/encryption/encryption.module.ts +9 -0
- package/nestjs/src/integrations/encryption/encryption.service.ts +31 -0
- package/nestjs/src/integrations/image/image.module.ts +9 -0
- package/nestjs/src/integrations/image/image.service.ts +61 -0
- package/nestjs/src/integrations/meta-business/meta-business.module.ts +10 -0
- package/nestjs/src/integrations/meta-business/meta-instagram.service.ts +94 -0
- package/nestjs/src/integrations/meta-business/meta-webhook.service.ts +52 -0
- package/nestjs/src/integrations/meta-business/meta-whatsapp.service.ts +254 -0
- package/nestjs/src/integrations/minio/minio.module.ts +9 -0
- package/nestjs/src/integrations/minio/minio.service.ts +88 -0
- package/nestjs/src/integrations/netgsm/netgsm.module.ts +8 -0
- package/nestjs/src/integrations/netgsm/netgsm.service.ts +17 -0
- package/nestjs/src/integrations/tektippay/tektippay.module.ts +8 -0
- package/nestjs/src/integrations/tektippay/tektippay.service.ts +23 -0
- package/nestjs/src/leads/dto/index.ts +2 -0
- package/nestjs/src/leads/dto/query-leads.dto.ts +50 -0
- package/nestjs/src/leads/dto/update-lead.dto.ts +26 -0
- package/nestjs/src/leads/leads.controller.ts +184 -0
- package/nestjs/src/leads/leads.module.ts +10 -0
- package/nestjs/src/leads/leads.service.ts +375 -0
- package/nestjs/src/logging/logging.controller.ts +82 -0
- package/nestjs/src/logging/logging.module.ts +11 -0
- package/nestjs/src/logging/logging.service.ts +180 -0
- package/nestjs/src/main.ts +86 -0
- package/nestjs/src/outbound-campaigns/dto/create-campaign.dto.ts +47 -0
- package/nestjs/src/outbound-campaigns/dto/index.ts +3 -0
- package/nestjs/src/outbound-campaigns/dto/update-campaign.dto.ts +31 -0
- package/nestjs/src/outbound-campaigns/dto/upload-entries.dto.ts +35 -0
- package/nestjs/src/outbound-campaigns/outbound-campaigns.controller.ts +307 -0
- package/nestjs/src/outbound-campaigns/outbound-campaigns.module.ts +13 -0
- package/nestjs/src/outbound-campaigns/outbound-campaigns.service.ts +471 -0
- package/nestjs/src/outbound-campaigns/processors/campaign-dispatch.processor.ts +366 -0
- package/nestjs/src/patients/documents.service.ts +231 -0
- package/nestjs/src/patients/dto/create-examination.dto.ts +34 -0
- package/nestjs/src/patients/dto/create-note.dto.ts +14 -0
- package/nestjs/src/patients/dto/create-patient.dto.ts +86 -0
- package/nestjs/src/patients/dto/create-photo-set.dto.ts +32 -0
- package/nestjs/src/patients/dto/index.ts +10 -0
- package/nestjs/src/patients/dto/update-examination.dto.ts +29 -0
- package/nestjs/src/patients/dto/update-medical-history.dto.ts +47 -0
- package/nestjs/src/patients/dto/update-patient.dto.ts +87 -0
- package/nestjs/src/patients/dto/update-photo-set.dto.ts +28 -0
- package/nestjs/src/patients/dto/upload-document.dto.ts +31 -0
- package/nestjs/src/patients/dto/upload-photo.dto.ts +27 -0
- package/nestjs/src/patients/examinations.service.ts +271 -0
- package/nestjs/src/patients/medical-history.service.ts +149 -0
- package/nestjs/src/patients/notes.service.ts +172 -0
- package/nestjs/src/patients/patients.controller.ts +485 -0
- package/nestjs/src/patients/patients.module.ts +22 -0
- package/nestjs/src/patients/patients.service.ts +412 -0
- package/nestjs/src/patients/photo-sets.service.ts +389 -0
- package/nestjs/src/phone-numbers/dto/create-phone-number.dto.ts +57 -0
- package/nestjs/src/phone-numbers/dto/index.ts +3 -0
- package/nestjs/src/phone-numbers/dto/update-phone-number.dto.ts +38 -0
- package/nestjs/src/phone-numbers/dto/update-schedule.dto.ts +39 -0
- package/nestjs/src/phone-numbers/phone-numbers.controller.ts +125 -0
- package/nestjs/src/phone-numbers/phone-numbers.module.ts +10 -0
- package/nestjs/src/phone-numbers/phone-numbers.service.ts +209 -0
- package/nestjs/src/plans/dto/create-plan.dto.ts +70 -0
- package/nestjs/src/plans/dto/index.ts +2 -0
- package/nestjs/src/plans/dto/update-plan.dto.ts +80 -0
- package/nestjs/src/plans/plans.controller.ts +50 -0
- package/nestjs/src/plans/plans.module.ts +10 -0
- package/nestjs/src/plans/plans.service.ts +115 -0
- package/nestjs/src/platform/dto/create-tenant.dto.ts +36 -0
- package/nestjs/src/platform/dto/index.ts +2 -0
- package/nestjs/src/platform/dto/update-tenant-platform.dto.ts +44 -0
- package/nestjs/src/platform/platform.controller.ts +79 -0
- package/nestjs/src/platform/platform.module.ts +10 -0
- package/nestjs/src/platform/platform.service.ts +301 -0
- package/nestjs/src/queue/queue.module.ts +56 -0
- package/nestjs/src/redis/redis.module.ts +20 -0
- package/nestjs/src/tenants/dto/index.ts +1 -0
- package/nestjs/src/tenants/dto/update-tenant.dto.ts +15 -0
- package/nestjs/src/tenants/tenants.controller.ts +45 -0
- package/nestjs/src/tenants/tenants.module.ts +10 -0
- package/nestjs/src/tenants/tenants.service.ts +41 -0
- package/nestjs/src/tools/adapters/elevenlabs-http.adapter.ts +51 -0
- package/nestjs/src/tools/adapters/elevenlabs-ws.adapter.ts +59 -0
- package/nestjs/src/tools/handlers/calendar.tools.ts +441 -0
- package/nestjs/src/tools/handlers/notification.tools.ts +34 -0
- package/nestjs/src/tools/handlers/operator.tools.ts +303 -0
- package/nestjs/src/tools/handlers/patient.tools.ts +242 -0
- package/nestjs/src/tools/handlers/payment.tools.ts +43 -0
- package/nestjs/src/tools/handlers/validation.tools.ts +152 -0
- package/nestjs/src/tools/tool-registry.service.ts +221 -0
- package/nestjs/src/tools/tool.decorator.ts +16 -0
- package/nestjs/src/tools/tool.interfaces.ts +26 -0
- package/nestjs/src/tools/tools.module.ts +50 -0
- package/nestjs/src/treatments/dto/create-plan-item.dto.ts +27 -0
- package/nestjs/src/treatments/dto/create-treatment-plan.dto.ts +69 -0
- package/nestjs/src/treatments/dto/create-treatment.dto.ts +59 -0
- package/nestjs/src/treatments/dto/index.ts +6 -0
- package/nestjs/src/treatments/dto/update-plan-item.dto.ts +23 -0
- package/nestjs/src/treatments/dto/update-treatment-plan.dto.ts +22 -0
- package/nestjs/src/treatments/dto/update-treatment.dto.ts +70 -0
- package/nestjs/src/treatments/treatment-plans.service.ts +362 -0
- package/nestjs/src/treatments/treatments.controller.ts +265 -0
- package/nestjs/src/treatments/treatments.module.ts +14 -0
- package/nestjs/src/treatments/treatments.service.ts +165 -0
- package/nestjs/src/users/doctor-profiles.service.ts +202 -0
- package/nestjs/src/users/dto/index.ts +4 -0
- package/nestjs/src/users/dto/invite-user.dto.ts +52 -0
- package/nestjs/src/users/dto/update-clinic-assignments.dto.ts +9 -0
- package/nestjs/src/users/dto/update-doctor-profile.dto.ts +49 -0
- package/nestjs/src/users/dto/update-user.dto.ts +41 -0
- package/nestjs/src/users/users.controller.ts +142 -0
- package/nestjs/src/users/users.module.ts +11 -0
- package/nestjs/src/users/users.service.ts +250 -0
- package/nestjs/src/webhooks/elevenlabs-tool.controller.ts +66 -0
- package/nestjs/src/webhooks/elevenlabs-webhook.controller.ts +60 -0
- package/nestjs/src/webhooks/meta-webhook.controller.ts +178 -0
- package/nestjs/src/webhooks/processors/elevenlabs-webhook.processor.ts +28 -0
- package/nestjs/src/webhooks/webhooks.module.ts +17 -0
- package/nestjs/src/whatsapp/chat-context.service.ts +281 -0
- package/nestjs/src/whatsapp/dto/add-blacklist.dto.ts +13 -0
- package/nestjs/src/whatsapp/dto/index.ts +2 -0
- package/nestjs/src/whatsapp/dto/send-message.dto.ts +14 -0
- package/nestjs/src/whatsapp/listeners/meta-message.listener.ts +579 -0
- package/nestjs/src/whatsapp/meta-auth.controller.ts +268 -0
- package/nestjs/src/whatsapp/meta-instagram-auth.controller.ts +244 -0
- package/nestjs/src/whatsapp/operator.service.ts +692 -0
- package/nestjs/src/whatsapp/processors/cost-sweep.processor.ts +130 -0
- package/nestjs/src/whatsapp/processors/grace.processor.ts +191 -0
- package/nestjs/src/whatsapp/processors/message-buffer.processor.ts +138 -0
- package/nestjs/src/whatsapp/processors/message-cleanup.processor.ts +148 -0
- package/nestjs/src/whatsapp/processors/meta-token-refresh.processor.ts +114 -0
- package/nestjs/src/whatsapp/processors/operator-expiry.processor.ts +105 -0
- package/nestjs/src/whatsapp/processors/profile-update.processor.ts +234 -0
- package/nestjs/src/whatsapp/processors/session-cleanup.processor.ts +178 -0
- package/nestjs/src/whatsapp/processors/session-labels.processor.ts +248 -0
- package/nestjs/src/whatsapp/whatsapp-agent.service.ts +2506 -0
- package/nestjs/src/whatsapp/whatsapp-recovery.service.ts +117 -0
- package/nestjs/src/whatsapp/whatsapp.controller.ts +398 -0
- package/nestjs/src/whatsapp/whatsapp.module.ts +51 -0
- package/nestjs/src/whatsapp/whatsapp.service.ts +592 -0
- package/nestjs/test/app.e2e-spec.ts +25 -0
- package/nestjs/test/jest-e2e.json +9 -0
- package/nestjs/tsconfig.build.json +4 -0
- package/nestjs/tsconfig.json +25 -0
- package/nginx.example.conf +18 -0
- package/package.json +47 -0
- package/scripts/addRecipient.ts +48 -0
- package/scripts/listRecipients.ts +31 -0
- package/scripts/migrate-agent-ref.ts +86 -0
- package/scripts/migrate-sessions.ts +183 -0
- package/scripts/promote.ts +27 -0
- package/scripts/retrigger.ts +84 -0
- package/scripts/seed.ts +435 -0
- package/scripts/testSend.ts +63 -0
- package/src/app.ts +85 -0
- package/src/config/agentPrompts.json +19 -0
- package/src/config/database.ts +21 -0
- package/src/config/env.ts +94 -0
- package/src/config/index.ts +86 -0
- package/src/controllers/webhook.controller.ts +150 -0
- package/src/errors/index.ts +9 -0
- package/src/hooks/webhookValidator.ts +55 -0
- package/src/index.ts +68 -0
- package/src/migrations/001_session-architecture.ts +138 -0
- package/src/migrations/002_agent-ref.ts +65 -0
- package/src/migrations/003_shift-schedule.ts +55 -0
- package/src/migrations/004_invert-shift-to-clinic-hours.ts +30 -0
- package/src/migrations/005_composite-baileys-chat-ids.ts +60 -0
- package/src/migrations/migration.model.ts +27 -0
- package/src/migrations/migration.routes.ts +40 -0
- package/src/migrations/migration.runner.ts +112 -0
- package/src/models/ConversationClaim.ts +17 -0
- package/src/models/ConversationEvaluation.ts +91 -0
- package/src/models/Summary.ts +77 -0
- package/src/models/Transcription.ts +68 -0
- package/src/models/WhatsAppRecipient.ts +37 -0
- package/src/modules/admin/admin.routes.ts +2385 -0
- package/src/modules/admin/elevenlabs-test-chat.routes.ts +193 -0
- package/src/modules/admin/whatsapp-test-chat.routes.ts +244 -0
- package/src/modules/agents/agent.model.ts +93 -0
- package/src/modules/agents/agent.routes.ts +65 -0
- package/src/modules/appointment-validation/appointment-validation.model.ts +163 -0
- package/src/modules/appointment-validation/appointment-validation.routes.ts +275 -0
- package/src/modules/appointment-validation/appointment-validation.service.ts +1028 -0
- package/src/modules/auth/auth.model.ts +42 -0
- package/src/modules/auth/auth.routes.ts +199 -0
- package/src/modules/auth/auth.service.ts +210 -0
- package/src/modules/auth/refresh-token.model.ts +26 -0
- package/src/modules/billing/billing-alert.model.ts +28 -0
- package/src/modules/billing/billing-period-snapshot.model.ts +68 -0
- package/src/modules/billing/billing.model.ts +42 -0
- package/src/modules/billing/billing.routes.ts +67 -0
- package/src/modules/billing/billing.service.ts +562 -0
- package/src/modules/billing/payment.model.ts +42 -0
- package/src/modules/calls/call.model.ts +102 -0
- package/src/modules/calls/call.routes.ts +118 -0
- package/src/modules/campaigns/campaign.model.ts +111 -0
- package/src/modules/campaigns/campaign.routes.ts +402 -0
- package/src/modules/campaigns/campaign.service.ts +99 -0
- package/src/modules/google-calendar/google-calendar.routes.ts +31 -0
- package/src/modules/inbound-call/inbound-call-config.model.ts +49 -0
- package/src/modules/inbound-call/inbound-call.routes.ts +289 -0
- package/src/modules/leads/lead.model.ts +40 -0
- package/src/modules/leads/lead.routes.ts +246 -0
- package/src/modules/logs/log.model.ts +27 -0
- package/src/modules/logs/log.routes.ts +102 -0
- package/src/modules/plans/plan.model.ts +45 -0
- package/src/modules/surveys/survey.model.ts +70 -0
- package/src/modules/surveys/survey.routes.ts +187 -0
- package/src/modules/tenants/tenant.model.ts +181 -0
- package/src/modules/tenants/tenant.routes.ts +78 -0
- package/src/modules/users/user.routes.ts +126 -0
- package/src/modules/webhooks/elevenlabs-tool.routes.ts +94 -0
- package/src/modules/webhooks/elevenlabs-tool.service.ts +491 -0
- package/src/modules/webhooks/elevenlabs.routes.ts +34 -0
- package/src/modules/webhooks/elevenlabs.service.ts +565 -0
- package/src/modules/webhooks/unipile.routes.ts +917 -0
- package/src/modules/whatsapp/appointment.model.ts +47 -0
- package/src/modules/whatsapp/operator-request.model.ts +58 -0
- package/src/modules/whatsapp/stt-usage.model.ts +30 -0
- package/src/modules/whatsapp/whatsapp-chat.model.ts +39 -0
- package/src/modules/whatsapp/whatsapp-contact-profile.model.ts +41 -0
- package/src/modules/whatsapp/whatsapp-message.model.ts +41 -0
- package/src/modules/whatsapp/whatsapp-session.model.ts +60 -0
- package/src/modules/whatsapp/whatsapp.routes.ts +1435 -0
- package/src/plugins/cors.ts +7 -0
- package/src/plugins/jwt.ts +18 -0
- package/src/plugins/rawBody.ts +12 -0
- package/src/plugins/rbac.ts +24 -0
- package/src/routes/admin.routes.ts +208 -0
- package/src/routes/health.routes.ts +12 -0
- package/src/routes/webhook.routes.ts +12 -0
- package/src/services/ai/base.ai.ts +132 -0
- package/src/services/ai/gemini.service.ts +41 -0
- package/src/services/ai/index.ts +24 -0
- package/src/services/ai/openai.service.ts +48 -0
- package/src/services/elevenlabs.service.ts +532 -0
- package/src/services/google-calendar.service.ts +656 -0
- package/src/services/inbound-call-schedule.service.ts +174 -0
- package/src/services/netgsm.service.ts +128 -0
- package/src/services/unipile.service.ts +200 -0
- package/src/services/whatsapp-agent.service.ts +2479 -0
- package/src/services/whatsapp.service.ts +245 -0
- package/src/templates/index.ts +71 -0
- package/src/templates/receptionist.ts +44 -0
- package/src/templates/survey.ts +44 -0
- package/src/types/index.ts +218 -0
- package/src/utils/logger.ts +83 -0
- package/tsconfig.json +19 -0
- package/web/.dockerignore +4 -0
- package/web/Dockerfile +18 -0
- package/web/README.md +73 -0
- package/web/components.json +23 -0
- package/web/eslint.config.js +23 -0
- package/web/index.html +14 -0
- package/web/nginx.conf +18 -0
- package/web/package-lock.json +10292 -0
- package/web/package.json +48 -0
- package/web/public/favicon.ico +0 -0
- package/web/public/vite.svg +1 -0
- package/web/src/App.tsx +191 -0
- package/web/src/assets/react.svg +1 -0
- package/web/src/components/Layout.tsx +261 -0
- package/web/src/components/LeadConversation.tsx +251 -0
- package/web/src/components/ProtectedRoute.tsx +20 -0
- package/web/src/components/conversation-review/CardAudioPlayer.tsx +200 -0
- package/web/src/components/conversation-review/CardEvaluation.tsx +351 -0
- package/web/src/components/conversation-review/CardMetadata.tsx +44 -0
- package/web/src/components/conversation-review/ConversationCard.tsx +95 -0
- package/web/src/components/conversation-review/ReviewContainer.tsx +120 -0
- package/web/src/components/conversation-review/ReviewFilters.tsx +88 -0
- package/web/src/components/empty-state.tsx +15 -0
- package/web/src/components/page-header.tsx +19 -0
- package/web/src/components/page-loader.tsx +32 -0
- package/web/src/components/pagination.tsx +38 -0
- package/web/src/components/stat-card.tsx +27 -0
- package/web/src/components/status-badge.tsx +125 -0
- package/web/src/components/ui/alert.tsx +66 -0
- package/web/src/components/ui/badge.tsx +48 -0
- package/web/src/components/ui/button.tsx +64 -0
- package/web/src/components/ui/card.tsx +92 -0
- package/web/src/components/ui/checkbox.tsx +32 -0
- package/web/src/components/ui/dialog.tsx +158 -0
- package/web/src/components/ui/dropdown-menu.tsx +255 -0
- package/web/src/components/ui/input.tsx +21 -0
- package/web/src/components/ui/label.tsx +22 -0
- package/web/src/components/ui/progress.tsx +29 -0
- package/web/src/components/ui/select.tsx +188 -0
- package/web/src/components/ui/separator.tsx +28 -0
- package/web/src/components/ui/sheet.tsx +123 -0
- package/web/src/components/ui/skeleton.tsx +13 -0
- package/web/src/components/ui/sonner.tsx +35 -0
- package/web/src/components/ui/table.tsx +116 -0
- package/web/src/components/ui/tabs.tsx +89 -0
- package/web/src/components/ui/textarea.tsx +18 -0
- package/web/src/components/ui/tooltip.tsx +57 -0
- package/web/src/components/whatsapp/ChatDetail.tsx +417 -0
- package/web/src/components/whatsapp/ChatHeader.tsx +78 -0
- package/web/src/components/whatsapp/ChatList.tsx +107 -0
- package/web/src/components/whatsapp/ChatListItem.tsx +60 -0
- package/web/src/components/whatsapp/MessageBubble.tsx +46 -0
- package/web/src/components/whatsapp/MessageInput.tsx +63 -0
- package/web/src/components/whatsapp/MessageStream.tsx +135 -0
- package/web/src/components/whatsapp/SessionDivider.tsx +65 -0
- package/web/src/components/whatsapp/SessionHistory.tsx +119 -0
- package/web/src/components/whatsapp/settings/AiSettingsTab.tsx +268 -0
- package/web/src/components/whatsapp/settings/CalendarTab.tsx +339 -0
- package/web/src/components/whatsapp/settings/ConnectionTab.tsx +236 -0
- package/web/src/components/whatsapp/settings/NotificationsTab.tsx +109 -0
- package/web/src/components/whatsapp/settings/OperatorTab.tsx +303 -0
- package/web/src/contexts/AuthContext.tsx +103 -0
- package/web/src/index.css +130 -0
- package/web/src/lib/api.ts +92 -0
- package/web/src/lib/utils.ts +6 -0
- package/web/src/main.tsx +10 -0
- package/web/src/pages/AppointmentDetail.tsx +206 -0
- package/web/src/pages/AppointmentValidation.tsx +157 -0
- package/web/src/pages/AppointmentValidationDetail.tsx +617 -0
- package/web/src/pages/AppointmentValidationNew.tsx +1005 -0
- package/web/src/pages/Appointments.tsx +283 -0
- package/web/src/pages/Billing.tsx +126 -0
- package/web/src/pages/CallDetail.tsx +293 -0
- package/web/src/pages/CallSettings.tsx +313 -0
- package/web/src/pages/Calls.tsx +188 -0
- package/web/src/pages/CampaignDetail.tsx +216 -0
- package/web/src/pages/CampaignNew.tsx +277 -0
- package/web/src/pages/CampaignResults.tsx +185 -0
- package/web/src/pages/Campaigns.tsx +171 -0
- package/web/src/pages/Dashboard.tsx +336 -0
- package/web/src/pages/InboundSchedule.tsx +246 -0
- package/web/src/pages/LeadDetail.tsx +183 -0
- package/web/src/pages/Leads.tsx +258 -0
- package/web/src/pages/Login.tsx +99 -0
- package/web/src/pages/Register.tsx +129 -0
- package/web/src/pages/Settings.tsx +133 -0
- package/web/src/pages/SurveyDetail.tsx +232 -0
- package/web/src/pages/SurveyPreview.tsx +179 -0
- package/web/src/pages/Surveys.tsx +207 -0
- package/web/src/pages/Users.tsx +199 -0
- package/web/src/pages/WhatsApp.tsx +147 -0
- package/web/src/pages/WhatsAppSettings.tsx +215 -0
- package/web/src/pages/admin/AdminBaileysMessageLog.tsx +331 -0
- package/web/src/pages/admin/AdminBaileysRawMessages.tsx +318 -0
- package/web/src/pages/admin/AdminConversationReview.tsx +116 -0
- package/web/src/pages/admin/AdminCredits.tsx +467 -0
- package/web/src/pages/admin/AdminElevenLabsAgentDetail.tsx +332 -0
- package/web/src/pages/admin/AdminElevenLabsAgents.tsx +164 -0
- package/web/src/pages/admin/AdminElevenLabsBatchCallDetail.tsx +214 -0
- package/web/src/pages/admin/AdminElevenLabsBatchCalls.tsx +293 -0
- package/web/src/pages/admin/AdminElevenLabsConversationDetail.tsx +230 -0
- package/web/src/pages/admin/AdminElevenLabsConversations.tsx +228 -0
- package/web/src/pages/admin/AdminElevenLabsInboundCalls.tsx +293 -0
- package/web/src/pages/admin/AdminElevenLabsPhoneNumbers.tsx +506 -0
- package/web/src/pages/admin/AdminElevenLabsTestChat.tsx +258 -0
- package/web/src/pages/admin/AdminElevenLabsWebhooks.tsx +289 -0
- package/web/src/pages/admin/AdminEvaluationDashboard.tsx +520 -0
- package/web/src/pages/admin/AdminLeads.tsx +339 -0
- package/web/src/pages/admin/AdminLogs.tsx +283 -0
- package/web/src/pages/admin/AdminMigrations.tsx +247 -0
- package/web/src/pages/admin/AdminPlans.tsx +313 -0
- package/web/src/pages/admin/AdminSystem.tsx +391 -0
- package/web/src/pages/admin/AdminTenantBillableItems.tsx +464 -0
- package/web/src/pages/admin/AdminTenantDetail.tsx +1317 -0
- package/web/src/pages/admin/AdminTenants.tsx +274 -0
- package/web/src/pages/admin/AdminWhatsApp.tsx +618 -0
- package/web/src/pages/admin/AdminWhatsAppTestChat.tsx +328 -0
- package/web/src/types/index.ts +242 -0
- package/web/tsconfig.app.json +32 -0
- package/web/tsconfig.json +13 -0
- package/web/tsconfig.node.json +26 -0
- package/web/vite.config.ts +23 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
37
|
+
const agentSchema = new mongoose_1.Schema({
|
|
38
|
+
tenant_id: {
|
|
39
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
40
|
+
ref: 'Tenant',
|
|
41
|
+
required: true,
|
|
42
|
+
index: true
|
|
43
|
+
},
|
|
44
|
+
phone_number: { type: String, required: true },
|
|
45
|
+
elevenlabs_agent_id: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true,
|
|
48
|
+
index: true
|
|
49
|
+
},
|
|
50
|
+
direction: {
|
|
51
|
+
type: String,
|
|
52
|
+
enum: ['inbound', 'outbound', 'both'],
|
|
53
|
+
required: true
|
|
54
|
+
},
|
|
55
|
+
agent_template: {
|
|
56
|
+
type: String,
|
|
57
|
+
enum: ['receptionist', 'survey', 'custom'],
|
|
58
|
+
required: true
|
|
59
|
+
},
|
|
60
|
+
config: {
|
|
61
|
+
voice_id: { type: String, required: true },
|
|
62
|
+
language: { type: String, default: 'tr' },
|
|
63
|
+
greeting: { type: String, default: '' },
|
|
64
|
+
template_data: { type: mongoose_1.Schema.Types.Mixed, default: {} }
|
|
65
|
+
},
|
|
66
|
+
post_call_processing: {
|
|
67
|
+
strategy: {
|
|
68
|
+
type: String,
|
|
69
|
+
enum: ['summarize', 'extract_survey', 'summarize_and_extract', 'none'],
|
|
70
|
+
default: 'summarize'
|
|
71
|
+
},
|
|
72
|
+
llm_provider: {
|
|
73
|
+
type: String,
|
|
74
|
+
enum: ['openai', 'gemini'],
|
|
75
|
+
default: 'openai'
|
|
76
|
+
},
|
|
77
|
+
whatsapp_notify: { type: Boolean, default: true },
|
|
78
|
+
notification_template: {
|
|
79
|
+
type: String,
|
|
80
|
+
enum: ['call_summary', 'survey_progress', 'custom'],
|
|
81
|
+
default: 'call_summary'
|
|
82
|
+
},
|
|
83
|
+
summary_prompt: { type: String, default: '' },
|
|
84
|
+
system_message: { type: String, default: '' },
|
|
85
|
+
whatsapp_message_template: { type: String, default: '' }
|
|
86
|
+
},
|
|
87
|
+
is_active: { type: Boolean, default: true }
|
|
88
|
+
}, {
|
|
89
|
+
timestamps: true
|
|
90
|
+
});
|
|
91
|
+
exports.default = mongoose_1.default.model('Agent', agentSchema);
|
|
92
|
+
//# sourceMappingURL=agent.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.model.js","sourceRoot":"","sources":["../../../src/modules/agents/agent.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsD;AAqCtD,MAAM,WAAW,GAAG,IAAI,iBAAM,CAAS;IACrC,SAAS,EAAE;QACT,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ;QAC3B,GAAG,EAAE,QAAQ;QACb,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,IAAI;KACZ;IACD,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC9C,mBAAmB,EAAE;QACnB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,IAAI;KACZ;IACD,SAAS,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC;QACrC,QAAQ,EAAE,IAAI;KACf;IACD,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,QAAQ,CAAC;QAC1C,QAAQ,EAAE,IAAI;KACf;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1C,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QACzC,QAAQ,E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};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = agentRoutes;
|
|
7
|
+
const agent_model_1 = __importDefault(require("./agent.model"));
|
|
8
|
+
const rbac_1 = require("../../plugins/rbac");
|
|
9
|
+
async function agentRoutes(fastify) {
|
|
10
|
+
fastify.addHook('preHandler', fastify.authenticate);
|
|
11
|
+
// GET /agents — list agents for tenant
|
|
12
|
+
fastify.get('/', {
|
|
13
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager', 'viewer')]
|
|
14
|
+
}, async (request) => {
|
|
15
|
+
const agents = await agent_model_1.default.find({ tenant_id: request.user.tenant_id })
|
|
16
|
+
.sort({ createdAt: -1 });
|
|
17
|
+
return { agents };
|
|
18
|
+
});
|
|
19
|
+
// GET /agents/:id
|
|
20
|
+
fastify.get('/:id', {
|
|
21
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager', 'viewer')]
|
|
22
|
+
}, async (request, reply) => {
|
|
23
|
+
const { id } = request.params;
|
|
24
|
+
const agent = await agent_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id });
|
|
25
|
+
if (!agent) {
|
|
26
|
+
return reply.status(404).send({ error: 'Agent not found' });
|
|
27
|
+
}
|
|
28
|
+
return { agent };
|
|
29
|
+
});
|
|
30
|
+
// PUT /agents/:id/config — update agent configuration
|
|
31
|
+
fastify.put('/:id/config', {
|
|
32
|
+
preHandler: [(0, rbac_1.requireRole)('admin')]
|
|
33
|
+
}, async (request, reply) => {
|
|
34
|
+
const { id } = request.params;
|
|
35
|
+
const { config, post_call_processing } = request.body;
|
|
36
|
+
const agent = await agent_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id });
|
|
37
|
+
if (!agent) {
|
|
38
|
+
return reply.status(404).send({ error: 'Agent not found' });
|
|
39
|
+
}
|
|
40
|
+
if (config)
|
|
41
|
+
Object.assign(agent.config, config);
|
|
42
|
+
if (post_call_processing)
|
|
43
|
+
Object.assign(agent.post_call_processing, post_call_processing);
|
|
44
|
+
await agent.save();
|
|
45
|
+
return { agent };
|
|
46
|
+
});
|
|
47
|
+
// POST /agents/:id/toggle — enable/disable
|
|
48
|
+
fastify.post('/:id/toggle', {
|
|
49
|
+
preHandler: [(0, rbac_1.requireRole)('admin')]
|
|
50
|
+
}, async (request, reply) => {
|
|
51
|
+
const { id } = request.params;
|
|
52
|
+
const agent = await agent_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id });
|
|
53
|
+
if (!agent) {
|
|
54
|
+
return reply.status(404).send({ error: 'Agent not found' });
|
|
55
|
+
}
|
|
56
|
+
agent.is_active = !agent.is_active;
|
|
57
|
+
await agent.save();
|
|
58
|
+
return { agent };
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=agent.routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.routes.js","sourceRoot":"","sources":["../../../src/modules/agents/agent.routes.ts"],"names":[],"mappings":";;;;;AAIA,8BA4DC;AA/DD,gEAAkC;AAClC,6CAAiD;AAElC,KAAK,UAAU,WAAW,CAAC,OAAwB;IAChE,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpD,uCAAuC;IACvC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;QACf,UAAU,EAAE,CAAC,IAAA,kBAAW,EAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;KACxD,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACnB,MAAM,MAAM,GAAG,MAAM,qBAAK,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;aACnE,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,kBAAkB;IAClB,OAAO,CAAC,GAA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AAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,oBAAoB;YAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;QAE1F,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,2CAA2C;IAC3C,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QAC1B,UAAU,EAAE,CAAC,IAAA,kBAAW,EAAC,OAAO,CAAC,CAAC;KACnC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC1B,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAwB,CAAC;QAChD,MAAM,KAAK,GAAG,MAAM,qBAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAClF,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC;QACnC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import mongoose, { Document } from 'mongoose';
|
|
2
|
+
export type BatchStatus = 'draft' | 'submitted' | 'in_progress' | 'completed' | 'cancelled';
|
|
3
|
+
export type EntryCallStatus = 'pending' | 'calling' | 'completed' | 'failed' | 'no_answer' | 'voicemail';
|
|
4
|
+
export type ValidationResult = 'confirmed' | 'cancelled' | 'reschedule' | 'unresolved';
|
|
5
|
+
export interface IColumnMapping {
|
|
6
|
+
patient_name: string;
|
|
7
|
+
patient_phone: string;
|
|
8
|
+
appointment_date: string;
|
|
9
|
+
appointment_time: string;
|
|
10
|
+
doctor_name?: string;
|
|
11
|
+
department?: string;
|
|
12
|
+
notes?: string;
|
|
13
|
+
external_id?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface IValidationEntry {
|
|
16
|
+
_id: mongoose.Types.ObjectId;
|
|
17
|
+
row_index: number;
|
|
18
|
+
external_id: string;
|
|
19
|
+
patient_name: string;
|
|
20
|
+
patient_phone: string;
|
|
21
|
+
appointment_date: string;
|
|
22
|
+
appointment_time: string;
|
|
23
|
+
doctor_name: string;
|
|
24
|
+
department: string;
|
|
25
|
+
notes: string;
|
|
26
|
+
raw_data: Record<string, string>;
|
|
27
|
+
call_status: EntryCallStatus;
|
|
28
|
+
attempts: number;
|
|
29
|
+
conversation_id: string | null;
|
|
30
|
+
validation_result: ValidationResult | null;
|
|
31
|
+
reschedule_request: string | null;
|
|
32
|
+
patient_message: string | null;
|
|
33
|
+
call_duration_secs: number;
|
|
34
|
+
called_at: Date | null;
|
|
35
|
+
result_at: Date | null;
|
|
36
|
+
}
|
|
37
|
+
export interface IBatchStats {
|
|
38
|
+
total: number;
|
|
39
|
+
confirmed: number;
|
|
40
|
+
cancelled: number;
|
|
41
|
+
reschedule: number;
|
|
42
|
+
unresolved: number;
|
|
43
|
+
no_answer: number;
|
|
44
|
+
voicemail: number;
|
|
45
|
+
pending: number;
|
|
46
|
+
failed: number;
|
|
47
|
+
}
|
|
48
|
+
export interface ICallSchedule {
|
|
49
|
+
call_date: string;
|
|
50
|
+
call_start_time: string;
|
|
51
|
+
call_end_time: string;
|
|
52
|
+
max_concurrent: number;
|
|
53
|
+
max_retries: number;
|
|
54
|
+
retry_delay_minutes: number;
|
|
55
|
+
}
|
|
56
|
+
export interface IAppointmentValidationBatch extends Document {
|
|
57
|
+
tenant_id: mongoose.Types.ObjectId;
|
|
58
|
+
created_by: mongoose.Types.ObjectId;
|
|
59
|
+
name: string;
|
|
60
|
+
status: BatchStatus;
|
|
61
|
+
elevenlabs_batch_id: string | null;
|
|
62
|
+
agent_id: mongoose.Types.ObjectId | null;
|
|
63
|
+
phone_number_id: string | null;
|
|
64
|
+
column_mapping: IColumnMapping;
|
|
65
|
+
call_schedule: ICallSchedule;
|
|
66
|
+
entries: IValidationEntry[];
|
|
67
|
+
stats: IBatchStats;
|
|
68
|
+
createdAt: Date;
|
|
69
|
+
updatedAt: Date;
|
|
70
|
+
}
|
|
71
|
+
declare const _default: mongoose.Model<IAppointmentValidationBatch, {}, {}, {}, mongoose.Document<unknown, {}, IAppointmentValidationBatch, {}, {}> & IAppointmentValidationBatch & Required<{
|
|
72
|
+
_id: mongoose.Types.ObjectId;
|
|
73
|
+
}> & {
|
|
74
|
+
__v: number;
|
|
75
|
+
}, any>;
|
|
76
|
+
export default _default;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
37
|
+
const validationEntrySchema = new mongoose_1.Schema({
|
|
38
|
+
row_index: { type: Number, required: true },
|
|
39
|
+
external_id: { type: String, default: '' },
|
|
40
|
+
patient_name: { type: String, required: true },
|
|
41
|
+
patient_phone: { type: String, required: true },
|
|
42
|
+
appointment_date: { type: String, required: true },
|
|
43
|
+
appointment_time: { type: String, required: true },
|
|
44
|
+
doctor_name: { type: String, default: '' },
|
|
45
|
+
department: { type: String, default: '' },
|
|
46
|
+
notes: { type: String, default: '' },
|
|
47
|
+
raw_data: { type: mongoose_1.Schema.Types.Mixed, default: {} },
|
|
48
|
+
call_status: {
|
|
49
|
+
type: String,
|
|
50
|
+
enum: ['pending', 'calling', 'completed', 'failed', 'no_answer', 'voicemail'],
|
|
51
|
+
default: 'pending',
|
|
52
|
+
},
|
|
53
|
+
attempts: { type: Number, default: 0 },
|
|
54
|
+
conversation_id: { type: String, default: null },
|
|
55
|
+
validation_result: {
|
|
56
|
+
type: String,
|
|
57
|
+
enum: ['confirmed', 'cancelled', 'reschedule', 'unresolved', null],
|
|
58
|
+
default: null,
|
|
59
|
+
},
|
|
60
|
+
reschedule_request: { type: String, default: null },
|
|
61
|
+
patient_message: { type: String, default: null },
|
|
62
|
+
call_duration_secs: { type: Number, default: 0 },
|
|
63
|
+
called_at: { type: Date, default: null },
|
|
64
|
+
result_at: { type: Date, default: null },
|
|
65
|
+
});
|
|
66
|
+
const columnMappingSchema = new mongoose_1.Schema({
|
|
67
|
+
patient_name: { type: String, required: true },
|
|
68
|
+
patient_phone: { type: String, required: true },
|
|
69
|
+
appointment_date: { type: String, required: true },
|
|
70
|
+
appointment_time: { type: String, required: true },
|
|
71
|
+
doctor_name: { type: String },
|
|
72
|
+
department: { type: String },
|
|
73
|
+
notes: { type: String },
|
|
74
|
+
external_id: { type: String },
|
|
75
|
+
}, { _id: false });
|
|
76
|
+
const batchStatsSchema = new mongoose_1.Schema({
|
|
77
|
+
total: { type: Number, default: 0 },
|
|
78
|
+
confirmed: { type: Number, default: 0 },
|
|
79
|
+
cancelled: { type: Number, default: 0 },
|
|
80
|
+
reschedule: { type: Number, default: 0 },
|
|
81
|
+
unresolved: { type: Number, default: 0 },
|
|
82
|
+
no_answer: { type: Number, default: 0 },
|
|
83
|
+
voicemail: { type: Number, default: 0 },
|
|
84
|
+
pending: { type: Number, default: 0 },
|
|
85
|
+
failed: { type: Number, default: 0 },
|
|
86
|
+
}, { _id: false });
|
|
87
|
+
const batchSchema = new mongoose_1.Schema({
|
|
88
|
+
tenant_id: { type: mongoose_1.Schema.Types.ObjectId, ref: 'Tenant', required: true },
|
|
89
|
+
created_by: { type: mongoose_1.Schema.Types.ObjectId, ref: 'User', required: true },
|
|
90
|
+
name: { type: String, required: true },
|
|
91
|
+
status: {
|
|
92
|
+
type: String,
|
|
93
|
+
enum: ['draft', 'submitted', 'in_progress', 'completed', 'cancelled'],
|
|
94
|
+
default: 'draft',
|
|
95
|
+
},
|
|
96
|
+
elevenlabs_batch_id: { type: String, default: null },
|
|
97
|
+
agent_id: { type: mongoose_1.Schema.Types.ObjectId, ref: 'Agent', default: null },
|
|
98
|
+
phone_number_id: { type: String, default: null },
|
|
99
|
+
column_mapping: { type: columnMappingSchema, required: true },
|
|
100
|
+
call_schedule: {
|
|
101
|
+
call_date: { type: String, required: true },
|
|
102
|
+
call_start_time: { type: String, default: '09:00' },
|
|
103
|
+
call_end_time: { type: String, default: '18:00' },
|
|
104
|
+
max_concurrent: { type: Number, default: 3 },
|
|
105
|
+
max_retries: { type: Number, default: 2 },
|
|
106
|
+
retry_delay_minutes: { type: Number, default: 30 },
|
|
107
|
+
},
|
|
108
|
+
entries: [validationEntrySchema],
|
|
109
|
+
stats: {
|
|
110
|
+
type: batchStatsSchema,
|
|
111
|
+
default: () => ({ total: 0, confirmed: 0, cancelled: 0, reschedule: 0, unresolved: 0, no_answer: 0, voicemail: 0, pending: 0, failed: 0 }),
|
|
112
|
+
},
|
|
113
|
+
}, { timestamps: true });
|
|
114
|
+
batchSchema.index({ tenant_id: 1, createdAt: -1 });
|
|
115
|
+
batchSchema.index({ elevenlabs_batch_id: 1 });
|
|
116
|
+
batchSchema.index({ 'entries.conversation_id': 1 });
|
|
117
|
+
exports.default = mongoose_1.default.model('AppointmentValidationBatch', batchSchema);
|
|
118
|
+
//# sourceMappingURL=appointment-validation.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appointment-validation.model.js","sourceRoot":"","sources":["../../../src/modules/appointment-validation/appointment-validation.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsD;AA6EtD,MAAM,qBAAqB,GAAG,IAAI,iBAAM,CAAmB;IACzD,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC3C,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;IAC1C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC9C,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,E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|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = appointmentValidationRoutes;
|
|
7
|
+
const appointment_validation_model_1 = __importDefault(require("./appointment-validation.model"));
|
|
8
|
+
const log_model_1 = __importDefault(require("../logs/log.model"));
|
|
9
|
+
const rbac_1 = require("../../plugins/rbac");
|
|
10
|
+
const appointment_validation_service_1 = require("./appointment-validation.service");
|
|
11
|
+
async function appointmentValidationRoutes(fastify) {
|
|
12
|
+
fastify.addHook('preHandler', fastify.authenticate);
|
|
13
|
+
fastify.addHook('preHandler', (0, rbac_1.requireFeature)('appointment_validation'));
|
|
14
|
+
// GET / — List batches (paginated)
|
|
15
|
+
fastify.get('/', {
|
|
16
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager', 'viewer')],
|
|
17
|
+
}, async (request) => {
|
|
18
|
+
const page = parseInt(request.query.page || '1', 10);
|
|
19
|
+
const limit = 20;
|
|
20
|
+
const skip = (page - 1) * limit;
|
|
21
|
+
const filter = { tenant_id: request.user.tenant_id };
|
|
22
|
+
if (request.query.status)
|
|
23
|
+
filter.status = request.query.status;
|
|
24
|
+
const [batches, total] = await Promise.all([
|
|
25
|
+
appointment_validation_model_1.default.find(filter)
|
|
26
|
+
.select('-entries')
|
|
27
|
+
.sort({ createdAt: -1 })
|
|
28
|
+
.skip(skip)
|
|
29
|
+
.limit(limit)
|
|
30
|
+
.populate('agent_id', 'phone_number elevenlabs_agent_id')
|
|
31
|
+
.populate('created_by', 'name'),
|
|
32
|
+
appointment_validation_model_1.default.countDocuments(filter),
|
|
33
|
+
]);
|
|
34
|
+
return { batches, total, page, totalPages: Math.ceil(total / limit) };
|
|
35
|
+
});
|
|
36
|
+
// POST / — Create batch
|
|
37
|
+
fastify.post('/', {
|
|
38
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
39
|
+
}, async (request, reply) => {
|
|
40
|
+
const body = request.body;
|
|
41
|
+
if (!body.name || !body.call_schedule?.call_date || !body.column_mapping || !body.entries?.length) {
|
|
42
|
+
return reply.status(400).send({ error: 'name, call_schedule.call_date, column_mapping, and entries are required' });
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const batch = await (0, appointment_validation_service_1.createBatch)(request.user.tenant_id, request.user.id, body);
|
|
46
|
+
return reply.status(201).send({ batch: { _id: batch._id, name: batch.name, status: batch.status, stats: batch.stats } });
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
const error = err;
|
|
50
|
+
return reply.status(error.statusCode || 500).send({ error: error.message });
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// GET /:id — Get batch with entries
|
|
54
|
+
fastify.get('/:id', {
|
|
55
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager', 'viewer')],
|
|
56
|
+
}, async (request, reply) => {
|
|
57
|
+
const { id } = request.params;
|
|
58
|
+
const batch = await appointment_validation_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id })
|
|
59
|
+
.populate('agent_id', 'phone_number elevenlabs_agent_id agent_template')
|
|
60
|
+
.populate('created_by', 'name');
|
|
61
|
+
if (!batch) {
|
|
62
|
+
return reply.status(404).send({ error: 'Batch not found' });
|
|
63
|
+
}
|
|
64
|
+
return { batch };
|
|
65
|
+
});
|
|
66
|
+
// POST /:id/submit — Submit to ElevenLabs
|
|
67
|
+
fastify.post('/:id/submit', {
|
|
68
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
69
|
+
}, async (request, reply) => {
|
|
70
|
+
const { id } = request.params;
|
|
71
|
+
const { force } = (request.query || {});
|
|
72
|
+
try {
|
|
73
|
+
const batch = await (0, appointment_validation_service_1.submitBatch)(id, request.user.tenant_id, { force: force === 'true' });
|
|
74
|
+
return { batch: { _id: batch._id, status: batch.status, elevenlabs_batch_id: batch.elevenlabs_batch_id, stats: batch.stats } };
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
const error = err;
|
|
78
|
+
return reply.status(error.statusCode || 500).send({ error: error.message });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// POST /:id/cancel — Cancel batch
|
|
82
|
+
fastify.post('/:id/cancel', {
|
|
83
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
84
|
+
}, async (request, reply) => {
|
|
85
|
+
const { id } = request.params;
|
|
86
|
+
try {
|
|
87
|
+
const batch = await (0, appointment_validation_service_1.cancelBatch)(id, request.user.tenant_id);
|
|
88
|
+
return { batch: { _id: batch._id, status: batch.status, stats: batch.stats } };
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
const error = err;
|
|
92
|
+
return reply.status(error.statusCode || 500).send({ error: error.message });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
// POST /:id/retry — Retry failed calls
|
|
96
|
+
fastify.post('/:id/retry', {
|
|
97
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
98
|
+
}, async (request, reply) => {
|
|
99
|
+
const { id } = request.params;
|
|
100
|
+
const { force } = (request.query || {});
|
|
101
|
+
try {
|
|
102
|
+
const batch = await (0, appointment_validation_service_1.retryBatch)(id, request.user.tenant_id, { force: force === 'true' });
|
|
103
|
+
return { batch: { _id: batch._id, status: batch.status, stats: batch.stats } };
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
const error = err;
|
|
107
|
+
return reply.status(error.statusCode || 500).send({ error: error.message });
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// POST /:id/entries/:entryId/retry — Retry a single entry
|
|
111
|
+
fastify.post('/:id/entries/:entryId/retry', {
|
|
112
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
113
|
+
}, async (request, reply) => {
|
|
114
|
+
const { id, entryId } = request.params;
|
|
115
|
+
try {
|
|
116
|
+
const batch = await (0, appointment_validation_service_1.retryEntry)(id, entryId, request.user.tenant_id);
|
|
117
|
+
return { batch: { _id: batch._id, status: batch.status, stats: batch.stats } };
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
const error = err;
|
|
121
|
+
return reply.status(error.statusCode || 500).send({ error: error.message });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
// GET /:id/export — CSV export
|
|
125
|
+
fastify.get('/:id/export', {
|
|
126
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager', 'viewer')],
|
|
127
|
+
}, async (request, reply) => {
|
|
128
|
+
const { id } = request.params;
|
|
129
|
+
const batch = await appointment_validation_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id });
|
|
130
|
+
if (!batch) {
|
|
131
|
+
return reply.status(404).send({ error: 'Batch not found' });
|
|
132
|
+
}
|
|
133
|
+
const csv = (0, appointment_validation_service_1.exportCSV)(batch);
|
|
134
|
+
reply
|
|
135
|
+
.header('Content-Type', 'text/csv; charset=utf-8')
|
|
136
|
+
.header('Content-Disposition', `attachment; filename="appointment-validation-${id}.csv"`)
|
|
137
|
+
.send(csv);
|
|
138
|
+
});
|
|
139
|
+
// GET /:id/logs — Batch-scoped logs
|
|
140
|
+
fastify.get('/:id/logs', {
|
|
141
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
142
|
+
}, async (request, reply) => {
|
|
143
|
+
const { id } = request.params;
|
|
144
|
+
const { page = '1', limit = '100', level } = request.query;
|
|
145
|
+
const batch = await appointment_validation_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id }, { entries: 1 }).lean();
|
|
146
|
+
if (!batch) {
|
|
147
|
+
return reply.status(404).send({ error: 'Batch not found' });
|
|
148
|
+
}
|
|
149
|
+
// Collect all conversation_ids + batch id for log lookup
|
|
150
|
+
const conversationIds = batch.entries
|
|
151
|
+
.map(e => e.conversation_id)
|
|
152
|
+
.filter(Boolean);
|
|
153
|
+
const batchIdStr = batch._id.toString();
|
|
154
|
+
const filter = {
|
|
155
|
+
$or: [
|
|
156
|
+
{ 'meta.batchId': batchIdStr },
|
|
157
|
+
...(conversationIds.length > 0
|
|
158
|
+
? [
|
|
159
|
+
{ 'meta.conversationId': { $in: conversationIds } },
|
|
160
|
+
{ 'meta.conversation_id': { $in: conversationIds } },
|
|
161
|
+
]
|
|
162
|
+
: []),
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
if (level && level !== 'all') {
|
|
166
|
+
filter.level = level;
|
|
167
|
+
}
|
|
168
|
+
const pageNum = Math.max(1, parseInt(page));
|
|
169
|
+
const limitNum = Math.min(500, Math.max(1, parseInt(limit)));
|
|
170
|
+
const [logs, total] = await Promise.all([
|
|
171
|
+
log_model_1.default.find(filter)
|
|
172
|
+
.sort({ timestamp: -1 })
|
|
173
|
+
.skip((pageNum - 1) * limitNum)
|
|
174
|
+
.limit(limitNum)
|
|
175
|
+
.lean(),
|
|
176
|
+
log_model_1.default.countDocuments(filter),
|
|
177
|
+
]);
|
|
178
|
+
return {
|
|
179
|
+
logs,
|
|
180
|
+
pagination: { page: pageNum, limit: limitNum, total, pages: Math.ceil(total / limitNum) },
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
// POST /:id/sync — Sync conversation statuses from ElevenLabs API
|
|
184
|
+
fastify.post('/:id/sync', {
|
|
185
|
+
preHandler: [(0, rbac_1.requireRole)('admin', 'manager')],
|
|
186
|
+
}, async (request, reply) => {
|
|
187
|
+
const { id } = request.params;
|
|
188
|
+
const batch = await appointment_validation_model_1.default.findOne({ _id: id, tenant_id: request.user.tenant_id });
|
|
189
|
+
if (!batch) {
|
|
190
|
+
return reply.status(404).send({ error: 'Batch not found' });
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const updated = await (0, appointment_validation_service_1.syncBatchConversations)(batch);
|
|
194
|
+
return { batch: { _id: updated._id, status: updated.status, stats: updated.stats } };
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
const error = err;
|
|
198
|
+
return reply.status(error.statusCode || 500).send({ error: error.message });
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=appointment-validation.routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appointment-validation.routes.js","sourceRoot":"","sources":["../../../src/modules/appointment-validation/appointment-validation.routes.ts"],"names":[],"mappings":";;;;;AAgBA,8CAkQC;AAjRD,kGAAwE;AACxE,kEAAoC;AACpC,6CAAiE;AACjE,qFAU0C;AAE3B,KAAK,UAAU,2BAA2B,CAAC,OAAwB;IAChF,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACpD,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,IAAA,qBAAc,EAAC,wBAAwB,CAAC,CAAC,CAAC;IAExE,mCAAmC;IACnC,OAAO,CAAC,GAAG,CAER,GAAG,EAAE;QACN,UAAU,EAAE,CAAC,IAAA,kBAAW,EAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;KACxD,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAEhC,MAAM,MAAM,GAA4B,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9E,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;QAE/D,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACzC,sCAA0B,CAAC,IAAI,CAAC,MAAM,CAAC;iBACpC,MAAM,CAAC,UAAU,CAAC;iBAClB,IAAI,CAAC,EAAE,SAAS,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
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IAppointmentValidationBatch, ValidationResult } from './appointment-validation.model';
|
|
2
|
+
export declare function normalizePhone(raw: string): string;
|
|
3
|
+
export declare function recalcStats(batch: IAppointmentValidationBatch): void;
|
|
4
|
+
interface CreateBatchInput {
|
|
5
|
+
name: string;
|
|
6
|
+
call_schedule: {
|
|
7
|
+
call_date: string;
|
|
8
|
+
call_start_time?: string;
|
|
9
|
+
call_end_time?: string;
|
|
10
|
+
max_concurrent?: number;
|
|
11
|
+
max_retries?: number;
|
|
12
|
+
retry_delay_minutes?: number;
|
|
13
|
+
};
|
|
14
|
+
column_mapping: {
|
|
15
|
+
patient_name: string;
|
|
16
|
+
patient_phone: string;
|
|
17
|
+
appointment_date: string;
|
|
18
|
+
appointment_time: string;
|
|
19
|
+
doctor_name?: string;
|
|
20
|
+
department?: string;
|
|
21
|
+
notes?: string;
|
|
22
|
+
};
|
|
23
|
+
entries: Array<{
|
|
24
|
+
row_index: number;
|
|
25
|
+
external_id?: string;
|
|
26
|
+
patient_name: string;
|
|
27
|
+
patient_phone: string;
|
|
28
|
+
appointment_date: string;
|
|
29
|
+
appointment_time: string;
|
|
30
|
+
doctor_name?: string;
|
|
31
|
+
department?: string;
|
|
32
|
+
notes?: string;
|
|
33
|
+
raw_data?: Record<string, string>;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
export declare function createBatch(tenantId: string, userId: string, data: CreateBatchInput): Promise<IAppointmentValidationBatch>;
|
|
37
|
+
export declare function submitBatch(batchId: string, tenantId: string, options?: {
|
|
38
|
+
force?: boolean;
|
|
39
|
+
}): Promise<IAppointmentValidationBatch>;
|
|
40
|
+
export declare function retryEntry(batchId: string, entryId: string, tenantId: string): Promise<IAppointmentValidationBatch>;
|
|
41
|
+
export declare function cancelBatch(batchId: string, tenantId: string): Promise<IAppointmentValidationBatch>;
|
|
42
|
+
export declare function retryBatch(batchId: string, tenantId: string, options?: {
|
|
43
|
+
force?: boolean;
|
|
44
|
+
}): Promise<IAppointmentValidationBatch>;
|
|
45
|
+
export declare function recordValidationResult(conversationId: string, tenantId: string, result: ValidationResult, rescheduleRequest?: string | null, patientMessage?: string | null): Promise<{
|
|
46
|
+
recorded: boolean;
|
|
47
|
+
batchId?: string;
|
|
48
|
+
}>;
|
|
49
|
+
export declare function syncBatchConversations(batch: IAppointmentValidationBatch): Promise<IAppointmentValidationBatch>;
|
|
50
|
+
export declare function resumeInterruptedBatches(): Promise<void>;
|
|
51
|
+
export declare function syncActiveBatches(): Promise<void>;
|
|
52
|
+
export declare function exportCSV(batch: IAppointmentValidationBatch): string;
|
|
53
|
+
export {};
|