adserver-dashboard 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/.ci/staging.yml +191 -0
- package/.dockerignore +117 -0
- package/.env +40 -0
- package/.env.staging +38 -0
- package/.gitlab-ci.yml +16 -0
- package/DEMO_STATUS.md +579 -0
- package/Dockerfile +61 -0
- package/Influence-MW-AdServer-12-02-2026/client/index.html +17 -0
- package/Influence-MW-AdServer-12-02-2026/client/public/favicon.png +0 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/App.tsx +91 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/advanced-map-drawer.tsx +1131 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ai-recommendation-panel.tsx +379 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/app-sidebar.tsx +183 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/auto-optimize-button.tsx +184 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/availability-drawer.tsx +385 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/brand-insights-panel.tsx +87 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/create-agency-drawer.tsx +198 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/create-brand-drawer.tsx +275 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/creative-assignment.tsx +526 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/data-table-toolbar.tsx +148 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/data-table.tsx +158 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/filter-drawer.tsx +356 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/form-insights-panel.tsx +82 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/geography-selector.tsx +699 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/header-user-menu.tsx +178 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/history-drawer.tsx +313 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/inventory-availability-section.tsx +176 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/inventory-format-drawer.tsx +173 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/inventory-selector.tsx +401 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/manual-inventory-drawer.tsx +368 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/mapbox-map.tsx +368 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/market-insights-panel.tsx +202 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/media-owner-drawer.tsx +217 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/metric-card.tsx +58 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/page-header.tsx +27 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/player-status-indicator.tsx +137 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/poi-targeting-drawer.tsx +298 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/recommendation-score-badge.tsx +102 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/recommended-inventories-panel.tsx +248 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/searchable-combobox.tsx +134 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/signal-visualizations.tsx +407 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/status-badge.tsx +35 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/theme-provider.tsx +73 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/theme-toggle.tsx +37 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/traffic-slider.tsx +75 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/accordion.tsx +56 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/alert-dialog.tsx +139 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/alert.tsx +59 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/aspect-ratio.tsx +5 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/avatar.tsx +51 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/badge.tsx +38 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/breadcrumb.tsx +115 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/button.tsx +62 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/calendar.tsx +68 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/card.tsx +85 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/carousel.tsx +260 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/chart.tsx +365 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/checkbox.tsx +28 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/collapsible.tsx +11 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/command.tsx +151 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/context-menu.tsx +198 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/dialog.tsx +122 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/drawer.tsx +118 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/dropdown-menu.tsx +198 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/form.tsx +178 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/hover-card.tsx +29 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/input-otp.tsx +69 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/input.tsx +23 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/label.tsx +24 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/menubar.tsx +256 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/navigation-menu.tsx +128 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/pagination.tsx +117 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/popover.tsx +29 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/progress.tsx +28 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/radio-group.tsx +42 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/resizable.tsx +45 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/scroll-area.tsx +46 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/select.tsx +160 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/separator.tsx +29 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/sheet.tsx +140 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/sidebar.tsx +727 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/skeleton.tsx +15 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/slider.tsx +26 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/switch.tsx +27 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/table.tsx +117 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/tabs.tsx +53 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/textarea.tsx +22 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toast.tsx +127 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toaster.tsx +33 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toggle-group.tsx +61 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toggle.tsx +43 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/tooltip.tsx +30 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/vendor-stores-modal.tsx +336 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/venue-type-drawer.tsx +359 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/venue-type-selector.tsx +436 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/hooks/use-mobile.tsx +19 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/hooks/use-toast.ts +191 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/index.css +244 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/lib/queryClient.ts +57 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/lib/utils.ts +39 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/lib/venue-taxonomy.ts +532 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/main.tsx +5 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/assign-creative.tsx +781 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/content-hub.tsx +995 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/custom-pois.tsx +431 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/dashboard.tsx +620 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/deal-detail.tsx +1062 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/deal-form.tsx +1570 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/deals.tsx +716 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/edit-creative-assignment.tsx +1051 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/geotargeting.tsx +675 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/integrations.tsx +425 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/line-item-creatives.tsx +622 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/line-item-form.tsx +3132 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/line-items.tsx +530 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/not-found.tsx +21 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/proof-of-play-upload.tsx +479 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/proof-of-play.tsx +880 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/reports.tsx +235 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/settings.tsx +652 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/signal-form.tsx +1117 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/signals.tsx +366 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/tags.tsx +332 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/venues.tsx +381 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/types/mapbox-gl-draw.d.ts +37 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/types/react-simple-maps.d.ts +57 -0
- package/Influence-MW-AdServer-12-02-2026/components.json +20 -0
- package/Influence-MW-AdServer-12-02-2026/docs/PRD.md +3373 -0
- package/Influence-MW-AdServer-12-02-2026/docs/influence-feature-mapping.csv +498 -0
- package/Influence-MW-AdServer-12-02-2026/drizzle.config.ts +14 -0
- package/Influence-MW-AdServer-12-02-2026/package-lock.json +9672 -0
- package/Influence-MW-AdServer-12-02-2026/package.json +118 -0
- package/Influence-MW-AdServer-12-02-2026/postcss.config.js +6 -0
- package/Influence-MW-AdServer-12-02-2026/replit.md +91 -0
- package/Influence-MW-AdServer-12-02-2026/script/build.ts +67 -0
- package/Influence-MW-AdServer-12-02-2026/scripts/create-miro-diagrams.cjs +318 -0
- package/Influence-MW-AdServer-12-02-2026/scripts/create-remaining-diagrams.cjs +270 -0
- package/Influence-MW-AdServer-12-02-2026/server/index.ts +103 -0
- package/Influence-MW-AdServer-12-02-2026/server/recommendation-service.ts +319 -0
- package/Influence-MW-AdServer-12-02-2026/server/routes.ts +1890 -0
- package/Influence-MW-AdServer-12-02-2026/server/static.ts +19 -0
- package/Influence-MW-AdServer-12-02-2026/server/storage.ts +2058 -0
- package/Influence-MW-AdServer-12-02-2026/server/vite.ts +58 -0
- package/Influence-MW-AdServer-12-02-2026/shared/schema.ts +1595 -0
- package/Influence-MW-AdServer-12-02-2026/tailwind.config.ts +107 -0
- package/Influence-MW-AdServer-12-02-2026/tsconfig.json +23 -0
- package/Influence-MW-AdServer-12-02-2026/vite.config.ts +40 -0
- package/LINE_ITEM_BUDGET_FIELD_MAPPING.md +178 -0
- package/PCM/.env.example +92 -0
- package/PCM/README.md +558 -0
- package/PCM/docs/TEST_CASES.md +422 -0
- package/PCM/index.js +106 -0
- package/PCM/package-lock.json +3282 -0
- package/PCM/package.json +32 -0
- package/PCM/replit.md +64 -0
- package/PCM/schema.sql +495 -0
- package/PCM/scripts/export-schema.js +183 -0
- package/PCM/scripts/seed-comprehensive.js +631 -0
- package/PCM/scripts/seed-production.js +477 -0
- package/PCM/src/config/db.js +56 -0
- package/PCM/src/config/swagger.js +5975 -0
- package/PCM/src/dto/EmailRequestDTO.js +166 -0
- package/PCM/src/middleware/errorHandler.js +52 -0
- package/PCM/src/middleware/logger.js +26 -0
- package/PCM/src/migrations/001_add_campaign_mode_fields.sql +36 -0
- package/PCM/src/migrations/002_create_deal_id_counters.sql +22 -0
- package/PCM/src/migrations/003_update_publishers_column.sql +15 -0
- package/PCM/src/migrations/004_add_direct_dealtype_and_advertiser.sql +5 -0
- package/PCM/src/migrations/005_add_programmatic_fields_and_update_enums.sql +31 -0
- package/PCM/src/migrations/006_add_line_item_programmatic_fields.sql +12 -0
- package/PCM/src/migrations/007_add_line_item_direct_fields.sql +15 -0
- package/PCM/src/migrations/008_add_inventory_fields.sql +45 -0
- package/PCM/src/migrations/009_move_inventory_fields_to_metadata.sql +32 -0
- package/PCM/src/migrations/010_add_draft_status_and_line_items_count.sql +23 -0
- package/PCM/src/migrations/011_add_planning_field.sql +21 -0
- package/PCM/src/migrations/012_fix_inventory_composite_pk.sql +17 -0
- package/PCM/src/migrations/013_make_external_id_optional.sql +3 -0
- package/PCM/src/migrations/014_create_change_history.sql +38 -0
- package/PCM/src/migrations/016_create_publisher_insertion_orders.sql +33 -0
- package/PCM/src/migrations/017_fix_line_item_id_fk_reference.sql +86 -0
- package/PCM/src/migrations/018_create_approval_tables.sql +44 -0
- package/PCM/src/migrations/019_add_encrypted_token_column.sql +2 -0
- package/PCM/src/migrations/020_add_rejection_reason_to_deals.sql +10 -0
- package/PCM/src/migrations/021_add_publisher_external_id_to_inventories.sql +12 -0
- package/PCM/src/migrations/022_add_line_item_extended_fields.sql +24 -0
- package/PCM/src/migrations/023_add_base_price_fields.sql +8 -0
- package/PCM/src/migrations/run-migrations.js +46 -0
- package/PCM/src/models/ApprovalOTP.js +51 -0
- package/PCM/src/models/ApprovalToken.js +79 -0
- package/PCM/src/models/ChangeHistory.js +107 -0
- package/PCM/src/models/Deal.js +186 -0
- package/PCM/src/models/DealIdCounter.js +28 -0
- package/PCM/src/models/LineItem.js +227 -0
- package/PCM/src/models/LineItemCreative.js +89 -0
- package/PCM/src/models/LineItemInventory.js +115 -0
- package/PCM/src/models/PublisherInsertionOrder.js +93 -0
- package/PCM/src/models/TransactionHistory.js +34 -0
- package/PCM/src/models/associations.js +81 -0
- package/PCM/src/routes/approval.js +321 -0
- package/PCM/src/routes/creatives.js +437 -0
- package/PCM/src/routes/deals.js +1638 -0
- package/PCM/src/routes/digitalSignage.js +242 -0
- package/PCM/src/routes/insertionOrders.js +380 -0
- package/PCM/src/routes/lineItems.js +926 -0
- package/PCM/src/routes/system.js +384 -0
- package/PCM/src/services/ApprovalService.js +885 -0
- package/PCM/src/services/CampaignImportConverter.js +631 -0
- package/PCM/src/services/CampaignModeService.js +273 -0
- package/PCM/src/services/CampaignStatusService.js +395 -0
- package/PCM/src/services/ChangeHistoryService.js +316 -0
- package/PCM/src/services/DealIdService.js +94 -0
- package/PCM/src/services/DealResponseFormatter.js +90 -0
- package/PCM/src/services/EmailNotificationService.js +315 -0
- package/PCM/src/services/LineItemResponseFormatter.js +122 -0
- package/PCM/src/services/LineItemStatusService.js +380 -0
- package/PCM/src/tests/comprehensiveTestRunner.js +360 -0
- package/PCM/src/tests/comprehensiveTests.js +1277 -0
- package/PCM/src/tests/dealTypeUnitTests.js +1058 -0
- package/PCM/src/tests/testRunner.js +248 -0
- package/PCM/src/utils/caseConverter.js +92 -0
- package/PCM/src/utils/dealCalculations.js +206 -0
- package/PCM/src/utils/lineItemPayloadNormalizer.js +41 -0
- package/PCM/src/utils/payloadNormalizer.js +34 -0
- package/PCM/src/utils/sourceNormalizer.js +56 -0
- package/PCM/src/validators/creativeValidator.js +27 -0
- package/PCM/src/validators/dealValidator.js +203 -0
- package/PCM/src/validators/lineItemValidator.js +489 -0
- package/PCM/tests/approval-flows.test.js +238 -0
- package/PCM/tests/approval-workflow.test.js +291 -0
- package/PCM/tests/campaign-import-converter.test.js +543 -0
- package/PCM/tests/campaign-import-e2e.test.js +520 -0
- package/PCM/tests/campaign-status.test.js +539 -0
- package/PCM/tests/direct-publisher-split-reimport.test.js +460 -0
- package/PCM/tests/e2e/digital-signage.test.js +145 -0
- package/PCM/tests/e2e/search-filter-pagination.test.js +399 -0
- package/PCM/tests/e2e-comprehensive.test.js +3446 -0
- package/PCM/tests/edge-cases.test.js +340 -0
- package/PCM/tests/line-item-status.test.js +340 -0
- package/PCM/tests/seller-account-external-ids.test.js +877 -0
- package/PCM/tests/source-validation.test.js +324 -0
- package/PRD.md +3373 -0
- package/README.md +186 -0
- package/client/index.html +35 -0
- package/client/public/DEMO_STATUS.md +579 -0
- package/client/public/img/MW-logo-trans_1754045676555.png +0 -0
- package/client/public/locales/ar/approval.json +144 -0
- package/client/public/locales/ar/buyer.json +61 -0
- package/client/public/locales/ar/campaigns.json +1 -0
- package/client/public/locales/ar/common.json +218 -0
- package/client/public/locales/ar/contentHub.json +266 -0
- package/client/public/locales/ar/creatives.json +79 -0
- package/client/public/locales/ar/dashboard.json +57 -0
- package/client/public/locales/ar/deals.json +886 -0
- package/client/public/locales/ar/dsp.json +131 -0
- package/client/public/locales/ar/inventory.json +201 -0
- package/client/public/locales/ar/lineItems.json +553 -0
- package/client/public/locales/ar/navigation.json +48 -0
- package/client/public/locales/ar/wizard.json +1 -0
- package/client/public/locales/en/approval.json +144 -0
- package/client/public/locales/en/buyer.json +65 -0
- package/client/public/locales/en/campaigns.json +1 -0
- package/client/public/locales/en/common.json +218 -0
- package/client/public/locales/en/contentHub.json +266 -0
- package/client/public/locales/en/creatives.json +79 -0
- package/client/public/locales/en/dashboard.json +57 -0
- package/client/public/locales/en/deals.json +886 -0
- package/client/public/locales/en/dsp.json +131 -0
- package/client/public/locales/en/inventory.json +201 -0
- package/client/public/locales/en/lineItems.json +659 -0
- package/client/public/locales/en/navigation.json +48 -0
- package/client/public/locales/en/wizard.json +1 -0
- package/client/public/locales/ja/approval.json +144 -0
- package/client/public/locales/ja/buyer.json +61 -0
- package/client/public/locales/ja/campaigns.json +1 -0
- package/client/public/locales/ja/common.json +218 -0
- package/client/public/locales/ja/contentHub.json +266 -0
- package/client/public/locales/ja/creatives.json +79 -0
- package/client/public/locales/ja/dashboard.json +57 -0
- package/client/public/locales/ja/deals.json +886 -0
- package/client/public/locales/ja/dsp.json +131 -0
- package/client/public/locales/ja/inventory.json +201 -0
- package/client/public/locales/ja/lineItems.json +553 -0
- package/client/public/locales/ja/navigation.json +48 -0
- package/client/public/locales/ja/wizard.json +1 -0
- package/client/public/locales/zh/approval.json +144 -0
- package/client/public/locales/zh/buyer.json +61 -0
- package/client/public/locales/zh/campaigns.json +1 -0
- package/client/public/locales/zh/common.json +218 -0
- package/client/public/locales/zh/contentHub.json +266 -0
- package/client/public/locales/zh/creatives.json +79 -0
- package/client/public/locales/zh/dashboard.json +57 -0
- package/client/public/locales/zh/deals.json +886 -0
- package/client/public/locales/zh/dsp.json +131 -0
- package/client/public/locales/zh/inventory.json +201 -0
- package/client/public/locales/zh/lineItems.json +553 -0
- package/client/public/locales/zh/navigation.json +48 -0
- package/client/public/locales/zh/wizard.json +1 -0
- package/client/public/manifest.json +36 -0
- package/client/src/App.tsx +464 -0
- package/client/src/components/app-sidebar.tsx +312 -0
- package/client/src/components/approval/approval-decision-form.test.tsx +294 -0
- package/client/src/components/approval/approval-decision-form.tsx +326 -0
- package/client/src/components/approval/approval-sheet.tsx +631 -0
- package/client/src/components/approval/line-item-details-sheet.tsx +371 -0
- package/client/src/components/approval/otp-verification.test.tsx +337 -0
- package/client/src/components/approval/otp-verification.tsx +180 -0
- package/client/src/components/content-hub/bulk-transcode-dialog.tsx +379 -0
- package/client/src/components/content-hub/content-hub-manager-v2.tsx +574 -0
- package/client/src/components/content-hub/content-hub-manager.tsx +330 -0
- package/client/src/components/content-hub/creative-card.tsx +456 -0
- package/client/src/components/content-hub/creative-detail-sheet.tsx +685 -0
- package/client/src/components/content-hub/creative-filters.tsx +457 -0
- package/client/src/components/content-hub/creative-grid.tsx +329 -0
- package/client/src/components/content-hub/creative-selector.tsx +415 -0
- package/client/src/components/content-hub/creative-upload.tsx +547 -0
- package/client/src/components/content-hub/folder-dialogs.tsx +445 -0
- package/client/src/components/content-hub/folder-list.tsx +280 -0
- package/client/src/components/content-hub/review-dialogs.tsx +268 -0
- package/client/src/components/content-hub/transcode-dialog.tsx +226 -0
- package/client/src/components/creative-library/creative-details-view.tsx +446 -0
- package/client/src/components/creative-library/creative-filters-panel.tsx +203 -0
- package/client/src/components/creative-library/creative-list.tsx +360 -0
- package/client/src/components/creative-library/creative-status-badge.tsx +71 -0
- package/client/src/components/creative-library/folder-card.tsx +78 -0
- package/client/src/components/creative-library/index.ts +27 -0
- package/client/src/components/creative-library/new-creative-card.tsx +211 -0
- package/client/src/components/creative-library/upload-creative-dialog.tsx +261 -0
- package/client/src/components/dashboard-overview.tsx +109 -0
- package/client/src/components/deals/approval-history-panel.test.tsx +240 -0
- package/client/src/components/deals/approval-history-panel.tsx +156 -0
- package/client/src/components/deals/deal-status-badge.tsx +92 -0
- package/client/src/components/deals/import-from-planner-dialog.tsx +399 -0
- package/client/src/components/deals/market-insights-panel.tsx +237 -0
- package/client/src/components/deals/reopen-deal-sheet.tsx +191 -0
- package/client/src/components/deals/request-approval-sheet.test.tsx +323 -0
- package/client/src/components/deals/request-approval-sheet.tsx +136 -0
- package/client/src/components/deals/resend-approval-sheet.tsx +201 -0
- package/client/src/components/direct-campaigns/campaign-card.tsx +283 -0
- package/client/src/components/direct-campaigns/deal-filter-panel.tsx +325 -0
- package/client/src/components/inventory/advanced-filters-panel.tsx +273 -0
- package/client/src/components/inventory/csv-upload-modal.tsx +639 -0
- package/client/src/components/inventory/inventory-availability-view.tsx +486 -0
- package/client/src/components/inventory/inventory-details-sheet.tsx +376 -0
- package/client/src/components/inventory/inventory-map-view.tsx +596 -0
- package/client/src/components/inventory/inventory-settings-menu.tsx +52 -0
- package/client/src/components/language-switcher.tsx +53 -0
- package/client/src/components/line-items/campaign-forecast-panel.tsx +138 -0
- package/client/src/components/line-items/form-insights.tsx +89 -0
- package/client/src/components/line-items/geofencing/LocationCsvUploadDrawer.tsx +100 -0
- package/client/src/components/line-items/geofencing/POIDropdown.tsx +379 -0
- package/client/src/components/line-items/geofencing/SelectedLocationsSidebar.tsx +436 -0
- package/client/src/components/line-items/geofencing/ViewFileLocationDrawer.tsx +199 -0
- package/client/src/components/line-items/geofencing/components/ExistingFilesTab.tsx +268 -0
- package/client/src/components/line-items/geofencing/components/TemplateDownloadSection.tsx +59 -0
- package/client/src/components/line-items/geofencing/components/UploadTab.tsx +215 -0
- package/client/src/components/line-items/geofencing-map.tsx +1270 -0
- package/client/src/components/line-items/inventory-availability-section.tsx +178 -0
- package/client/src/components/line-items/line-item-schedule-manager.tsx +313 -0
- package/client/src/components/line-items/manual-inventory-drawer.tsx +346 -0
- package/client/src/components/line-items/planner-inventory-card.tsx +495 -0
- package/client/src/components/line-items/planner-schedule-grid.tsx +495 -0
- package/client/src/components/line-items/schedule-rule-editor.tsx +649 -0
- package/client/src/components/line-items/schedule-rule-types.ts +122 -0
- package/client/src/components/line-items/steps/creatives-step.tsx +681 -0
- package/client/src/components/line-items/steps/inventory-schedule-step.tsx +1596 -0
- package/client/src/components/line-items/steps/inventory-step.tsx +1533 -0
- package/client/src/components/line-items/steps/line-item-details-step.tsx +916 -0
- package/client/src/components/line-items/steps/schedule-step.tsx +273 -0
- package/client/src/components/line-items/steps/summary-step.tsx +680 -0
- package/client/src/components/line-items/steps/targeting-step.tsx +1708 -0
- package/client/src/components/product-switcher.tsx +105 -0
- package/client/src/components/protected-route.tsx +49 -0
- package/client/src/components/skip-link.tsx +22 -0
- package/client/src/components/stat-card.tsx +53 -0
- package/client/src/components/status-badge.tsx +96 -0
- package/client/src/components/ui/hierarchical-venue-selector.tsx +389 -0
- package/client/src/components/ui/toaster.tsx +111 -0
- package/client/src/contexts/auth-context.tsx +181 -0
- package/client/src/contexts/sidebar-state.tsx +50 -0
- package/client/src/contexts/theme-context.tsx +66 -0
- package/client/src/data/campaign-data.json +107 -0
- package/client/src/data/countries.json +22 -0
- package/client/src/hooks/use-approval.ts +366 -0
- package/client/src/hooks/use-keyboard-shortcuts.ts +74 -0
- package/client/src/hooks/use-media-query.ts +46 -0
- package/client/src/hooks/use-mobile.tsx +19 -0
- package/client/src/hooks/use-page-title.ts +21 -0
- package/client/src/hooks/use-toast.ts +195 -0
- package/client/src/index.css +694 -0
- package/client/src/lib/__tests__/accessibility.test.ts +104 -0
- package/client/src/lib/__tests__/date-utils.test.ts +199 -0
- package/client/src/lib/__tests__/dsp-buyer-api.test.ts +127 -0
- package/client/src/lib/__tests__/dsp-buyer-integration.test.ts +247 -0
- package/client/src/lib/__tests__/storage-utils.test.ts +167 -0
- package/client/src/lib/__tests__/utils.test.ts +57 -0
- package/client/src/lib/accessibility.ts +141 -0
- package/client/src/lib/api-config.ts +9 -0
- package/client/src/lib/auth-service.ts +209 -0
- package/client/src/lib/campaign-creative-api.ts +82 -0
- package/client/src/lib/company-api.ts +61 -0
- package/client/src/lib/content-hub-api.ts +407 -0
- package/client/src/lib/creative-mapper.ts +61 -0
- package/client/src/lib/date-utils.ts +119 -0
- package/client/src/lib/deal-helpers.ts +220 -0
- package/client/src/lib/dsp-buyer-api.ts +196 -0
- package/client/src/lib/geo-import-api.ts +151 -0
- package/client/src/lib/google-poi-api.ts +305 -0
- package/client/src/lib/i18n/__tests__/formatting.test.ts +202 -0
- package/client/src/lib/i18n/formatting.ts +130 -0
- package/client/src/lib/i18n/index.ts +8 -0
- package/client/src/lib/i18n-compat.ts +76 -0
- package/client/src/lib/influence-deals-api.ts +896 -0
- package/client/src/lib/inventory-api.ts +399 -0
- package/client/src/lib/oauth-service.ts +678 -0
- package/client/src/lib/poi-types.ts +75 -0
- package/client/src/lib/queryClient.ts +144 -0
- package/client/src/lib/recommendation-api.ts +380 -0
- package/client/src/lib/storage-utils.ts +104 -0
- package/client/src/lib/tolgee.ts +85 -0
- package/client/src/lib/utils.ts +0 -0
- package/client/src/main.tsx +67 -0
- package/client/src/mapbox-draw-modes.d.ts +32 -0
- package/client/src/pages/all-folders.tsx +203 -0
- package/client/src/pages/auth-callback.tsx +115 -0
- package/client/src/pages/buyer-form.tsx +339 -0
- package/client/src/pages/buyer-list.tsx +622 -0
- package/client/src/pages/content-hub.tsx +1358 -0
- package/client/src/pages/create-deal.tsx +2093 -0
- package/client/src/pages/creative-assignment-page.tsx +548 -0
- package/client/src/pages/creatives.tsx +5 -0
- package/client/src/pages/custom-pois.tsx +425 -0
- package/client/src/pages/dashboard.tsx +615 -0
- package/client/src/pages/deal-history.tsx +434 -0
- package/client/src/pages/deal-line-items.tsx +1703 -0
- package/client/src/pages/demo-status.tsx +113 -0
- package/client/src/pages/direct-campaign-details.tsx +361 -0
- package/client/src/pages/direct-campaigns-new.tsx +824 -0
- package/client/src/pages/dsp-form.tsx +803 -0
- package/client/src/pages/dsp-list.tsx +239 -0
- package/client/src/pages/folder-content.tsx +336 -0
- package/client/src/pages/integrations.tsx +429 -0
- package/client/src/pages/line-item-creatives.tsx +789 -0
- package/client/src/pages/line-item-detail-page.tsx +684 -0
- package/client/src/pages/line-item-form-page.tsx +3261 -0
- package/client/src/pages/line-item-wizard.tsx +1207 -0
- package/client/src/pages/login.tsx +154 -0
- package/client/src/pages/not-found.tsx +23 -0
- package/client/src/pages/proof-of-play.tsx +397 -0
- package/client/src/pages/public-approval.tsx +551 -0
- package/client/src/pages/reports.tsx +231 -0
- package/client/src/pages/settings.tsx +760 -0
- package/client/src/pages/signals.tsx +389 -0
- package/client/src/pages/tags.tsx +318 -0
- package/client/src/pages/test-results.tsx +328 -0
- package/client/src/store/hooks.ts +5 -0
- package/client/src/store/index.ts +15 -0
- package/client/src/store/mapMarkerLocationsSlice.ts +241 -0
- package/client/src/styles/design-tokens.css +324 -0
- package/client/src/test/setup.ts +261 -0
- package/client/src/test/test-utils.tsx +40 -0
- package/client/src/types/approval.ts +221 -0
- package/client/src/types/content-hub.ts +209 -0
- package/client/src/types/geofencing.ts +67 -0
- package/client/src/types/transcoding.ts +140 -0
- package/client/src/vite-env.d.ts +18 -0
- package/components.json +20 -0
- package/creative-api.json +1 -0
- package/docs/AI_REFERENCE.md +459 -0
- package/docs/MWDesign-Prompt.md +132 -0
- package/docs/MWDesign-System.md +344 -0
- package/docs/test-plan.md +277 -0
- package/e2e/AUTONOMOUS-TESTING.md +406 -0
- package/e2e/README.md +219 -0
- package/e2e/autonomous-flow.spec.ts +308 -0
- package/e2e/debug-sso.spec.ts +163 -0
- package/e2e/direct-campaigns.spec.ts +219 -0
- package/e2e/explore-sso.spec.ts +149 -0
- package/e2e/fixtures/auth.ts +26 -0
- package/e2e/fixtures/enhanced-test.ts +331 -0
- package/e2e/pagination.spec.ts +280 -0
- package/e2e/view-toggle.spec.ts +312 -0
- package/generated-icon.png +0 -0
- package/i18next-scanner.config.cjs +46 -0
- package/package.json +141 -0
- package/playwright.config.ts +93 -0
- package/postcss.config.js +6 -0
- package/replit.md +196 -0
- package/screenshot-after-login.png +0 -0
- package/screenshot-contenthub-grid.png +0 -0
- package/screenshot-contenthub-list-fixed.png +0 -0
- package/screenshot-contenthub-list.png +0 -0
- package/screenshot-create-deal.png +0 -0
- package/screenshot-dashboard.png +0 -0
- package/screenshot-deals.png +0 -0
- package/screenshot-login-filled.png +0 -0
- package/screenshot-login.png +0 -0
- package/screenshot.mjs +24 -0
- package/scripts/deploy-stg.sh +185 -0
- package/shared/direct-io-schema.ts +383 -0
- package/shared/schema.ts +439 -0
- package/shared/screen-types.ts +149 -0
- package/springdocDefault.json +1 -0
- package/swagger-ui-bundle.js +2 -0
- package/swagger-ui-init.js +10316 -0
- package/tailwind.config.ts +282 -0
- package/terraform/README.md +306 -0
- package/terraform/cloudfront.tf +289 -0
- package/terraform/ecs.tf +727 -0
- package/terraform/environments/dev.tfvars +59 -0
- package/terraform/environments/production.tfvars +60 -0
- package/terraform/main.tf +47 -0
- package/terraform/outputs.tf +145 -0
- package/terraform/s3.tf +192 -0
- package/terraform/variables.tf +226 -0
- package/terraform/waf.tf +165 -0
- package/terraform-frontend/.terraform.lock.hcl +25 -0
- package/terraform-frontend/README.md +85 -0
- package/terraform-frontend/cloudfront.tf +125 -0
- package/terraform-frontend/main.tf +31 -0
- package/terraform-frontend/outputs.tf +24 -0
- package/terraform-frontend/terraform.tfvars +12 -0
- package/terraform-frontend/variables.tf +53 -0
- package/tsconfig.json +23 -0
- package/vite.config.ts +226 -0
- package/vitest.config.ts +56 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { createHash } from 'crypto';
|
|
3
|
+
import { validateSourceForImport, INTERNAL_SOURCES } from '../utils/sourceNormalizer.js';
|
|
4
|
+
|
|
5
|
+
export const PayloadType = {
|
|
6
|
+
PROGRAMMATIC_STANDARD: 'PROGRAMMATIC_STANDARD',
|
|
7
|
+
DIRECT_STANDARD: 'DIRECT_STANDARD',
|
|
8
|
+
DIRECT_PUBLISHER_SPLIT: 'DIRECT_PUBLISHER_SPLIT'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class CampaignImportConverter {
|
|
12
|
+
|
|
13
|
+
static _validateAndGetSource(source, campaign) {
|
|
14
|
+
const rawSource = source || campaign?.source || 'external';
|
|
15
|
+
const validation = validateSourceForImport(rawSource);
|
|
16
|
+
|
|
17
|
+
if (!validation.valid) {
|
|
18
|
+
const error = new Error(validation.error);
|
|
19
|
+
error.code = 'INVALID_SOURCE_FOR_IMPORT';
|
|
20
|
+
error.statusCode = 400;
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return rawSource;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static convert(externalPayload, payloadType, options = {}) {
|
|
28
|
+
switch (payloadType) {
|
|
29
|
+
case PayloadType.PROGRAMMATIC_STANDARD:
|
|
30
|
+
return this.convertProgrammaticStandard(externalPayload, options);
|
|
31
|
+
case PayloadType.DIRECT_STANDARD:
|
|
32
|
+
return this.convertDirectStandard(externalPayload, options);
|
|
33
|
+
case PayloadType.DIRECT_PUBLISHER_SPLIT:
|
|
34
|
+
return this.convertDirectPublisherSplit(externalPayload, options);
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Unknown payload type: ${payloadType}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static convertProgrammaticStandard(externalPayload, options = {}) {
|
|
41
|
+
const { campaign, lineItems = [] } = externalPayload;
|
|
42
|
+
const source = this._validateAndGetSource(options.source, campaign);
|
|
43
|
+
|
|
44
|
+
const deal = this._buildProgrammaticDeal(campaign, source);
|
|
45
|
+
const convertedLineItems = lineItems.map((li, index) =>
|
|
46
|
+
this._buildProgrammaticLineItem(li, campaign, index, source)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
type: PayloadType.PROGRAMMATIC_STANDARD,
|
|
51
|
+
deal,
|
|
52
|
+
lineItems: convertedLineItems,
|
|
53
|
+
metadata: {
|
|
54
|
+
convertedAt: new Date().toISOString(),
|
|
55
|
+
source,
|
|
56
|
+
originalLineItemCount: lineItems.length
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static convertDirectStandard(externalPayload, options = {}) {
|
|
62
|
+
const { campaign, lineItems = [] } = externalPayload;
|
|
63
|
+
const source = this._validateAndGetSource(options.source, campaign);
|
|
64
|
+
|
|
65
|
+
const deal = this._buildDirectDeal(campaign, source);
|
|
66
|
+
const convertedLineItems = lineItems.map((li, index) =>
|
|
67
|
+
this._buildDirectLineItem(li, campaign, index, source)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
type: PayloadType.DIRECT_STANDARD,
|
|
72
|
+
deal,
|
|
73
|
+
lineItems: convertedLineItems,
|
|
74
|
+
metadata: {
|
|
75
|
+
convertedAt: new Date().toISOString(),
|
|
76
|
+
source,
|
|
77
|
+
originalLineItemCount: lineItems.length
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static convertDirectPublisherSplit(externalPayload, options = {}) {
|
|
83
|
+
const { campaign, inventories = [] } = externalPayload;
|
|
84
|
+
const source = this._validateAndGetSource(options.source, campaign);
|
|
85
|
+
|
|
86
|
+
const campaignWithTotal = { ...campaign, _totalInventories: inventories.length };
|
|
87
|
+
const deal = this._buildDirectDeal(campaignWithTotal, source);
|
|
88
|
+
const { scheduledInventories, nonScheduledInventories } = this._separateBySchedule(inventories);
|
|
89
|
+
|
|
90
|
+
const lineItems = [];
|
|
91
|
+
let lineItemIndex = 0;
|
|
92
|
+
|
|
93
|
+
for (const inv of scheduledInventories) {
|
|
94
|
+
lineItems.push(this._buildLineItemFromScheduledInventory(inv, campaignWithTotal, lineItemIndex++, source));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const groups = this._groupInventoriesByPublisherAndDuration(nonScheduledInventories);
|
|
98
|
+
for (const group of Object.values(groups)) {
|
|
99
|
+
lineItems.push(this._buildLineItemFromPublisherGroup(group, campaignWithTotal, lineItemIndex++, source));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const publisherGroups = this._groupInventoriesByPublisherForIO(inventories);
|
|
103
|
+
const publishers = Object.values(publisherGroups).map(g => ({
|
|
104
|
+
id: g.publisher.id,
|
|
105
|
+
name: g.publisher.name,
|
|
106
|
+
externalId: g.publisher.externalId || null
|
|
107
|
+
}));
|
|
108
|
+
|
|
109
|
+
deal.publishers = publishers;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
type: PayloadType.DIRECT_PUBLISHER_SPLIT,
|
|
113
|
+
deal,
|
|
114
|
+
lineItems,
|
|
115
|
+
metadata: {
|
|
116
|
+
convertedAt: new Date().toISOString(),
|
|
117
|
+
source,
|
|
118
|
+
originalInventoryCount: inventories.length,
|
|
119
|
+
scheduledInventoryCount: scheduledInventories.length,
|
|
120
|
+
groupedInventoryCount: nonScheduledInventories.length,
|
|
121
|
+
lineItemCount: lineItems.length,
|
|
122
|
+
publisherCount: Object.keys(publisherGroups).length,
|
|
123
|
+
publisherBreakdown: Object.entries(publisherGroups).map(([id, g]) => ({
|
|
124
|
+
publisherId: id,
|
|
125
|
+
publisherName: g.publisher.name,
|
|
126
|
+
inventoryCount: g.inventories.length
|
|
127
|
+
})),
|
|
128
|
+
groupBreakdown: Object.entries(groups).map(([key, g]) => ({
|
|
129
|
+
groupKey: key,
|
|
130
|
+
publisherId: g.publisher.id,
|
|
131
|
+
publisherName: g.publisher.name,
|
|
132
|
+
resolution: g.resolution,
|
|
133
|
+
duration: g.duration,
|
|
134
|
+
inventoryCount: g.inventories.length
|
|
135
|
+
}))
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static _buildProgrammaticDeal(campaign, source) {
|
|
141
|
+
return {
|
|
142
|
+
source,
|
|
143
|
+
externalId: campaign.externalId || campaign.id || `ext-${Date.now()}`,
|
|
144
|
+
name: campaign.name,
|
|
145
|
+
mode: 'PROGRAMMATIC',
|
|
146
|
+
dealType: campaign.dealType || 'PRIVATE_AUCTION',
|
|
147
|
+
status: campaign.status || 'DRAFT',
|
|
148
|
+
currency: campaign.currency || 'USD',
|
|
149
|
+
advertiser: campaign.advertiser || {},
|
|
150
|
+
seller: campaign.seller,
|
|
151
|
+
account: campaign.account,
|
|
152
|
+
programmatic: {
|
|
153
|
+
buyers: campaign.buyers || [],
|
|
154
|
+
auctionType: this._resolveAuctionType(campaign.dealType, campaign.auctionType),
|
|
155
|
+
transactionType: campaign.transactionType || 'SPOT',
|
|
156
|
+
costType: campaign.costType || 'CPM',
|
|
157
|
+
deliveryGoal: campaign.deliveryGoal,
|
|
158
|
+
netCost: campaign.netCost,
|
|
159
|
+
netCostPerDay: campaign.netCostPerDay,
|
|
160
|
+
impressions: campaign.impressions,
|
|
161
|
+
published: campaign.published,
|
|
162
|
+
nonBillable: campaign.nonBillable,
|
|
163
|
+
stopBidRequests: campaign.stopBidRequests
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static _buildDirectDeal(campaign, source) {
|
|
169
|
+
const budgetConfig = campaign.budgetSetup || {};
|
|
170
|
+
return {
|
|
171
|
+
source,
|
|
172
|
+
externalId: campaign.externalId || campaign.id || `ext-${Date.now()}`,
|
|
173
|
+
name: campaign.name,
|
|
174
|
+
mode: 'DIRECT',
|
|
175
|
+
dealType: 'DIRECT',
|
|
176
|
+
status: campaign.status || 'DRAFT',
|
|
177
|
+
currency: campaign.currency || campaign.marketSelection?.currency || 'USD',
|
|
178
|
+
startDate: campaign.startDate,
|
|
179
|
+
endDate: campaign.endDate,
|
|
180
|
+
timezoneId: campaign.timezoneId,
|
|
181
|
+
brand: campaign.brand,
|
|
182
|
+
clientType: campaign.clientType || 'DIRECT_ADVERTISER',
|
|
183
|
+
approvalEmails: campaign.approvalEmails || [],
|
|
184
|
+
advertiser: campaign.advertiser || {},
|
|
185
|
+
account: campaign.account || undefined,
|
|
186
|
+
_totalInventories: campaign._totalInventories,
|
|
187
|
+
direct: {
|
|
188
|
+
brand: campaign.brand,
|
|
189
|
+
clientType: campaign.clientType || 'DIRECT_ADVERTISER',
|
|
190
|
+
approvalEmails: campaign.approvalEmails || [],
|
|
191
|
+
marketSelection: campaign.marketSelection || {
|
|
192
|
+
country: campaign.country || 'US',
|
|
193
|
+
currency: campaign.currency || 'USD'
|
|
194
|
+
},
|
|
195
|
+
budgetSetup: budgetConfig.budgetAmount !== undefined ? budgetConfig : {
|
|
196
|
+
currency: campaign.currency || 'USD',
|
|
197
|
+
budgetAmount: campaign.budget || 0
|
|
198
|
+
},
|
|
199
|
+
campaignGoal: campaign.campaignGoal || {
|
|
200
|
+
type: 'IMPRESSIONS',
|
|
201
|
+
targetValue: campaign.targetImpressions || 0
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static _buildProgrammaticLineItem(lineItem, campaign, index, source) {
|
|
208
|
+
const externalId = lineItem.externalId || lineItem.id || `li-${source}-${index}-${Date.now()}`;
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
source,
|
|
212
|
+
externalId,
|
|
213
|
+
name: lineItem.name || `${campaign.name} - Line Item ${index + 1}`,
|
|
214
|
+
dealType: campaign.dealType || 'PRIVATE_AUCTION',
|
|
215
|
+
creativeType: lineItem.creativeType || campaign.creativeType || 'DISPLAY',
|
|
216
|
+
status: lineItem.status || 'DRAFT',
|
|
217
|
+
startDate: lineItem.startDate || campaign.startDate,
|
|
218
|
+
endDate: lineItem.endDate || campaign.endDate,
|
|
219
|
+
timezoneId: lineItem.timezoneId || campaign.timezoneId,
|
|
220
|
+
currency: lineItem.currency || campaign.currency || 'USD',
|
|
221
|
+
resolutions: lineItem.resolutions || [],
|
|
222
|
+
schedule: lineItem.schedule || campaign.schedule,
|
|
223
|
+
pacing: lineItem.pacing || campaign.pacing,
|
|
224
|
+
priority: lineItem.priority,
|
|
225
|
+
customFees: lineItem.customFees,
|
|
226
|
+
frequencyCap: lineItem.frequencyCap,
|
|
227
|
+
trafficAllocation: lineItem.trafficAllocation,
|
|
228
|
+
inventorySource: lineItem.inventorySource,
|
|
229
|
+
programmatic: {
|
|
230
|
+
auctionType: this._resolveAuctionType(campaign.dealType, lineItem.auctionType || campaign.auctionType),
|
|
231
|
+
duration: lineItem.duration || campaign.duration,
|
|
232
|
+
impressionType: lineItem.impressionType || campaign.impressionType || 'SPOT',
|
|
233
|
+
thresholdCountPerDay: lineItem.thresholdCountPerDay,
|
|
234
|
+
deliveryGoal: lineItem.deliveryGoal,
|
|
235
|
+
costType: lineItem.costType || campaign.costType || 'CPM',
|
|
236
|
+
bidFloor: lineItem.bidFloor || campaign.bidFloor,
|
|
237
|
+
netCost: lineItem.netCost,
|
|
238
|
+
netCostPerDay: lineItem.netCostPerDay,
|
|
239
|
+
impressions: lineItem.impressions,
|
|
240
|
+
admCreativeSync: lineItem.admCreativeSync,
|
|
241
|
+
nonBillable: lineItem.nonBillable,
|
|
242
|
+
stopBidRequests: lineItem.stopBidRequests
|
|
243
|
+
},
|
|
244
|
+
inventories: this._convertInventories(lineItem.inventories || [])
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static _buildDirectLineItem(lineItem, campaign, index, source) {
|
|
249
|
+
const externalId = lineItem.externalId || lineItem.id || `li-${source}-${index}-${Date.now()}`;
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
source,
|
|
253
|
+
externalId,
|
|
254
|
+
name: lineItem.name || `${campaign.name} - Line Item ${index + 1}`,
|
|
255
|
+
dealType: 'DIRECT',
|
|
256
|
+
creativeType: lineItem.creativeType || campaign.creativeType || 'DISPLAY',
|
|
257
|
+
status: lineItem.status || 'DRAFT',
|
|
258
|
+
startDate: lineItem.startDate || campaign.startDate,
|
|
259
|
+
endDate: lineItem.endDate || campaign.endDate,
|
|
260
|
+
timezoneId: lineItem.timezoneId || campaign.timezoneId,
|
|
261
|
+
currency: lineItem.currency || campaign.currency || 'USD',
|
|
262
|
+
resolutions: lineItem.resolutions || [],
|
|
263
|
+
schedule: lineItem.schedule || campaign.schedule,
|
|
264
|
+
pacing: lineItem.pacing || campaign.pacing,
|
|
265
|
+
creativeSource: lineItem.creativeSource || 'ADVERTISER',
|
|
266
|
+
priority: lineItem.priority,
|
|
267
|
+
customFees: lineItem.customFees,
|
|
268
|
+
frequencyCap: lineItem.frequencyCap,
|
|
269
|
+
trafficAllocation: lineItem.trafficAllocation,
|
|
270
|
+
inventorySource: lineItem.inventorySource,
|
|
271
|
+
direct: {
|
|
272
|
+
budgetSetup: lineItem.budgetSetup || campaign.budgetSetup,
|
|
273
|
+
campaignGoal: lineItem.campaignGoal || campaign.campaignGoal,
|
|
274
|
+
targeting: lineItem.targeting || campaign.targeting,
|
|
275
|
+
planning: lineItem.planning
|
|
276
|
+
},
|
|
277
|
+
targeting: lineItem.targeting || campaign.targeting,
|
|
278
|
+
deliveryTargeting: lineItem.deliveryTargeting || campaign.deliveryTargeting,
|
|
279
|
+
inventories: this._convertInventoriesWithPlanning(lineItem.inventories || [], lineItem.planning)
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
static _generateInventoryFingerprint(inventories) {
|
|
284
|
+
const identifiers = inventories.map(inv => {
|
|
285
|
+
const id = inv.id || inv.inventoryId;
|
|
286
|
+
if (id) return id;
|
|
287
|
+
return `fallback:${inv.name || 'unnamed'}:${inv.resolution || 'nores'}:${inv.duration || 'nodur'}`;
|
|
288
|
+
});
|
|
289
|
+
const sortedIds = identifiers.sort().join(',');
|
|
290
|
+
return createHash('md5').update(sortedIds).digest('hex').substring(0, 8);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
static _buildLineItemFromPublisherGroup(group, campaign, index, source) {
|
|
294
|
+
const { publisher, duration, inventories } = group;
|
|
295
|
+
const campaignExtId = campaign.externalId || campaign.id || 'unknown';
|
|
296
|
+
const durationSlug = (duration || 'default').toString().replace(/[^\w]/g, '_');
|
|
297
|
+
const inventoryFingerprint = this._generateInventoryFingerprint(inventories);
|
|
298
|
+
const externalId = `${campaignExtId}-${publisher.id}-${durationSlug}-${inventoryFingerprint}`;
|
|
299
|
+
|
|
300
|
+
const resolutions = [...new Set(inventories.map(inv => inv.resolution || inv.size).filter(Boolean))];
|
|
301
|
+
const sizes = [...new Set(inventories.map(inv => inv.size || inv.resolution).filter(Boolean))];
|
|
302
|
+
|
|
303
|
+
const aggregatedPlanning = this._aggregatePlanning(inventories);
|
|
304
|
+
|
|
305
|
+
// Explicitly pass campaign._totalInventories to maintain context during budget derivation
|
|
306
|
+
const budgetSetup = this._deriveBudgetFromPlanning(aggregatedPlanning, campaign, inventories.length);
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
source,
|
|
310
|
+
externalId,
|
|
311
|
+
name: `${campaign.name} - ${publisher.name}`,
|
|
312
|
+
mode: 'DIRECT',
|
|
313
|
+
dealType: 'DIRECT',
|
|
314
|
+
creativeType: campaign.creativeType || 'DISPLAY',
|
|
315
|
+
status: campaign.status || 'DRAFT',
|
|
316
|
+
startDate: campaign.startDate,
|
|
317
|
+
endDate: campaign.endDate,
|
|
318
|
+
timezoneId: campaign.timezoneId,
|
|
319
|
+
currency: campaign.currency || 'USD',
|
|
320
|
+
publisherId: publisher.id,
|
|
321
|
+
resolutions,
|
|
322
|
+
sizes,
|
|
323
|
+
schedule: campaign.schedule,
|
|
324
|
+
pacing: campaign.pacing,
|
|
325
|
+
creativeSource: campaign.creativeSource || 'ADVERTISER',
|
|
326
|
+
totalInventories: inventories.length,
|
|
327
|
+
priority: campaign.priority,
|
|
328
|
+
customFees: campaign.customFees,
|
|
329
|
+
frequencyCap: campaign.frequencyCap,
|
|
330
|
+
trafficAllocation: campaign.trafficAllocation,
|
|
331
|
+
inventorySource: campaign.inventorySource,
|
|
332
|
+
direct: {
|
|
333
|
+
budgetSetup,
|
|
334
|
+
campaignGoal: this._splitGoal(campaign.campaignGoal, inventories.length, campaign._totalInventories),
|
|
335
|
+
targeting: campaign.targeting,
|
|
336
|
+
planning: aggregatedPlanning
|
|
337
|
+
},
|
|
338
|
+
targeting: campaign.targeting,
|
|
339
|
+
deliveryTargeting: campaign.deliveryTargeting,
|
|
340
|
+
inventories: this._convertInventoriesWithPlanning(inventories, null)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
static _separateBySchedule(inventories) {
|
|
345
|
+
const scheduledInventories = [];
|
|
346
|
+
const nonScheduledInventories = [];
|
|
347
|
+
|
|
348
|
+
for (const inventory of inventories) {
|
|
349
|
+
if (inventory.schedule && Array.isArray(inventory.schedule) && inventory.schedule.length > 0) {
|
|
350
|
+
scheduledInventories.push(inventory);
|
|
351
|
+
} else {
|
|
352
|
+
nonScheduledInventories.push(inventory);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return { scheduledInventories, nonScheduledInventories };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
static _groupInventoriesByPublisherAndDuration(nonScheduledInventories) {
|
|
360
|
+
const groups = {};
|
|
361
|
+
|
|
362
|
+
for (const inventory of nonScheduledInventories) {
|
|
363
|
+
const publisherId = inventory.publisher?.id || inventory.publisherId || 'unknown';
|
|
364
|
+
const publisherName = inventory.publisher?.name || inventory.publisherName || 'Unknown Publisher';
|
|
365
|
+
const publisherExternalId = inventory.publisher?.externalId ?? inventory.publisherExternalId ?? inventory.publisher_external_id ?? null;
|
|
366
|
+
const duration = inventory.duration || 'default';
|
|
367
|
+
|
|
368
|
+
const groupKey = `${publisherId}-${duration}`;
|
|
369
|
+
|
|
370
|
+
if (!groups[groupKey]) {
|
|
371
|
+
groups[groupKey] = {
|
|
372
|
+
publisher: { id: publisherId, name: publisherName, externalId: publisherExternalId },
|
|
373
|
+
duration,
|
|
374
|
+
inventories: []
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
groups[groupKey].inventories.push(inventory);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return groups;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
static _buildLineItemFromScheduledInventory(inventory, campaign, index, source) {
|
|
385
|
+
const publisherId = inventory.publisher?.id || inventory.publisherId || 'unknown';
|
|
386
|
+
const publisherName = inventory.publisher?.name || inventory.publisherName || 'Unknown Publisher';
|
|
387
|
+
const resolution = inventory.resolution || inventory.size;
|
|
388
|
+
const inventoryName = inventory.name || inventory.adUnitCode || `Screen-${index + 1}`;
|
|
389
|
+
|
|
390
|
+
const campaignExtId = campaign.externalId || campaign.id || 'unknown';
|
|
391
|
+
const resolutionSlug = (resolution || 'default').replace(/[^\w]/g, '_');
|
|
392
|
+
const durationSlug = (inventory.duration || campaign.duration || 'default').toString().replace(/[^\w]/g, '_');
|
|
393
|
+
const inventoryId = inventory.id || inventory.externalId || `inv-${index}`;
|
|
394
|
+
const externalId = `${campaignExtId}-${publisherId}-${resolutionSlug}-${durationSlug}-${inventoryId}`;
|
|
395
|
+
|
|
396
|
+
const schedule = Array.isArray(inventory.schedule) && inventory.schedule.length > 0
|
|
397
|
+
? inventory.schedule
|
|
398
|
+
: (campaign.schedule || []);
|
|
399
|
+
|
|
400
|
+
return {
|
|
401
|
+
source,
|
|
402
|
+
externalId,
|
|
403
|
+
name: `${campaign.name} - ${publisherName} - ${inventoryName}`,
|
|
404
|
+
mode: 'DIRECT',
|
|
405
|
+
dealType: 'DIRECT',
|
|
406
|
+
creativeType: campaign.creativeType || 'DISPLAY',
|
|
407
|
+
status: campaign.status || 'DRAFT',
|
|
408
|
+
startDate: campaign.startDate,
|
|
409
|
+
endDate: campaign.endDate,
|
|
410
|
+
timezoneId: inventory.timezone || campaign.timezoneId,
|
|
411
|
+
currency: campaign.currency || 'USD',
|
|
412
|
+
publisherId,
|
|
413
|
+
resolutions: resolution ? [resolution] : [],
|
|
414
|
+
sizes: resolution ? [resolution] : [],
|
|
415
|
+
schedule,
|
|
416
|
+
pacing: campaign.pacing,
|
|
417
|
+
creativeSource: campaign.creativeSource || 'ADVERTISER',
|
|
418
|
+
totalInventories: 1,
|
|
419
|
+
priority: campaign.priority,
|
|
420
|
+
customFees: campaign.customFees,
|
|
421
|
+
frequencyCap: campaign.frequencyCap,
|
|
422
|
+
trafficAllocation: campaign.trafficAllocation,
|
|
423
|
+
inventorySource: campaign.inventorySource,
|
|
424
|
+
direct: {
|
|
425
|
+
budgetSetup: this._deriveBudgetFromPlanning(inventory.planning, campaign, 1),
|
|
426
|
+
campaignGoal: this._splitGoal(campaign.campaignGoal, 1, campaign._totalInventories),
|
|
427
|
+
targeting: campaign.targeting,
|
|
428
|
+
planning: inventory.planning
|
|
429
|
+
},
|
|
430
|
+
targeting: campaign.targeting,
|
|
431
|
+
deliveryTargeting: campaign.deliveryTargeting,
|
|
432
|
+
inventories: this._convertInventoriesWithPlanning([inventory], null)
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
static _groupInventoriesByPublisherForIO(inventories) {
|
|
437
|
+
const groups = {};
|
|
438
|
+
|
|
439
|
+
for (const inventory of inventories) {
|
|
440
|
+
const publisherId = inventory.publisher?.id || inventory.publisherId || 'unknown';
|
|
441
|
+
const publisherName = inventory.publisher?.name || inventory.publisherName || 'Unknown Publisher';
|
|
442
|
+
const publisherExternalId = inventory.publisher?.externalId ?? inventory.publisherExternalId ?? inventory.publisher_external_id ?? null;
|
|
443
|
+
|
|
444
|
+
if (!groups[publisherId]) {
|
|
445
|
+
groups[publisherId] = {
|
|
446
|
+
publisher: { id: publisherId, name: publisherName, externalId: publisherExternalId },
|
|
447
|
+
inventories: []
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
groups[publisherId].inventories.push(inventory);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return groups;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
static _convertInventories(inventories) {
|
|
458
|
+
return inventories.map(inv => ({
|
|
459
|
+
id: inv.id || inv.externalId || `inv-${uuidv4()}`,
|
|
460
|
+
adUnitCode: inv.adUnitCode,
|
|
461
|
+
name: inv.name,
|
|
462
|
+
referenceId: inv.referenceId,
|
|
463
|
+
deviceId: inv.deviceId,
|
|
464
|
+
size: inv.size || inv.resolution,
|
|
465
|
+
publisher: inv.publisher ? {
|
|
466
|
+
id: inv.publisher.id,
|
|
467
|
+
name: inv.publisher.name,
|
|
468
|
+
externalId: inv.publisher.externalId ?? inv.publisherExternalId ?? inv.publisher_external_id ?? null
|
|
469
|
+
} : {
|
|
470
|
+
id: inv.publisherId,
|
|
471
|
+
name: inv.publisherName,
|
|
472
|
+
externalId: inv.publisherExternalId ?? inv.publisher_external_id ?? null
|
|
473
|
+
},
|
|
474
|
+
latitude: inv.latitude || inv.location?.lat,
|
|
475
|
+
longitude: inv.longitude || inv.location?.lng,
|
|
476
|
+
venueType: inv.venueType,
|
|
477
|
+
venueTypeIds: inv.venueTypeIds,
|
|
478
|
+
thumbnail: inv.thumbnail,
|
|
479
|
+
timezone: inv.timezone,
|
|
480
|
+
countryIso2: inv.countryIso2,
|
|
481
|
+
countryIso3: inv.countryIso3,
|
|
482
|
+
spotsPerHour: inv.spotsPerHour,
|
|
483
|
+
spotDuration: inv.spotDuration
|
|
484
|
+
}));
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
static _convertInventoriesWithPlanning(inventories, defaultPlanning) {
|
|
488
|
+
return inventories.map(inv => ({
|
|
489
|
+
...this._convertInventories([inv])[0],
|
|
490
|
+
planning: inv.planning || defaultPlanning || undefined
|
|
491
|
+
}));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
static _splitBudget(budgetSetup, groupSize, totalInventories) {
|
|
495
|
+
if (!budgetSetup) return undefined;
|
|
496
|
+
|
|
497
|
+
const ratio = totalInventories > 0 ? groupSize / totalInventories : 1;
|
|
498
|
+
|
|
499
|
+
return {
|
|
500
|
+
...budgetSetup,
|
|
501
|
+
budgetAmount: budgetSetup.budgetAmount ? Math.round(budgetSetup.budgetAmount * ratio * 100) / 100 : undefined
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
static _deriveBudgetFromPlanning(planning, campaign, inventoryCount) {
|
|
506
|
+
const estimatedCost = planning?.pricing?.estimatedCost;
|
|
507
|
+
const budgetConfig = campaign.budgetSetup || {};
|
|
508
|
+
const campaignBudget = budgetConfig.budgetAmount ?? campaign.budget;
|
|
509
|
+
const totalInventories = campaign._totalInventories || inventoryCount;
|
|
510
|
+
|
|
511
|
+
if (estimatedCost !== undefined && estimatedCost !== null) {
|
|
512
|
+
let budgetAmount = estimatedCost;
|
|
513
|
+
|
|
514
|
+
if (campaignBudget !== undefined && campaignBudget !== null && campaignBudget > 0) {
|
|
515
|
+
const ratio = totalInventories > 0 ? inventoryCount / totalInventories : 1;
|
|
516
|
+
const maxAllocatedForThisGroup = campaignBudget * ratio;
|
|
517
|
+
|
|
518
|
+
if (budgetAmount > maxAllocatedForThisGroup) {
|
|
519
|
+
console.log(`[Import] Capping budget ${budgetAmount} to proportional limit ${maxAllocatedForThisGroup.toFixed(2)} (Total Budget: ${campaignBudget}, Share: ${ratio.toFixed(2)})`);
|
|
520
|
+
budgetAmount = maxAllocatedForThisGroup;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return {
|
|
525
|
+
currency: campaign.currency || budgetConfig.currency || 'USD',
|
|
526
|
+
budgetType: budgetConfig.budgetType || 'TOTAL',
|
|
527
|
+
budgetAmount: Math.round(budgetAmount * 100) / 100
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return this._splitBudget(campaign.budgetSetup, inventoryCount, totalInventories);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
static _splitGoal(campaignGoal, groupSize, totalInventories) {
|
|
535
|
+
if (!campaignGoal) return undefined;
|
|
536
|
+
|
|
537
|
+
const ratio = totalInventories > 0 ? groupSize / totalInventories : 1;
|
|
538
|
+
|
|
539
|
+
return {
|
|
540
|
+
...campaignGoal,
|
|
541
|
+
targetValue: campaignGoal.targetValue ? Math.round(campaignGoal.targetValue * ratio) : undefined
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
static _aggregatePlanning(inventories) {
|
|
546
|
+
const plannings = inventories.map(i => i.planning).filter(Boolean);
|
|
547
|
+
if (plannings.length === 0) return undefined;
|
|
548
|
+
|
|
549
|
+
return {
|
|
550
|
+
capacity: {
|
|
551
|
+
campaignDays: plannings[0]?.capacity?.campaignDays,
|
|
552
|
+
available: {
|
|
553
|
+
slots: this._sum(plannings, p => p.capacity?.available?.slots),
|
|
554
|
+
playTimeSec: this._sum(plannings, p => p.capacity?.available?.playTimeSec),
|
|
555
|
+
maxImpressions: this._sum(plannings, p => p.capacity?.available?.maxImpressions)
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
allocation: {
|
|
559
|
+
slots: this._sum(plannings, p => p.allocation?.slots),
|
|
560
|
+
playTimeSec: this._sum(plannings, p => p.allocation?.playTimeSec),
|
|
561
|
+
sov: this._avg(plannings, p => p.allocation?.sov),
|
|
562
|
+
sot: this._avg(plannings, p => p.allocation?.sot)
|
|
563
|
+
},
|
|
564
|
+
estimates: {
|
|
565
|
+
impressions: this._sum(plannings, p => p.estimates?.impressions),
|
|
566
|
+
reach: this._sum(plannings, p => p.estimates?.reach),
|
|
567
|
+
frequency: this._avg(plannings, p => p.estimates?.frequency)
|
|
568
|
+
},
|
|
569
|
+
pricing: {
|
|
570
|
+
cpm: this._avg(plannings, p => p.pricing?.cpm),
|
|
571
|
+
estimatedCost: this._sum(plannings, p => p.pricing?.estimatedCost)
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
static _sum(arr, getter) {
|
|
577
|
+
const values = arr.map(getter).filter(v => v !== undefined && v !== null);
|
|
578
|
+
return values.length > 0 ? values.reduce((a, b) => a + b, 0) : undefined;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
static _avg(arr, getter) {
|
|
582
|
+
const values = arr.map(getter).filter(v => v !== undefined && v !== null);
|
|
583
|
+
return values.length > 0 ? values.reduce((a, b) => a + b, 0) / values.length : undefined;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
static _resolveAuctionType(dealType, providedAuctionType) {
|
|
587
|
+
if (providedAuctionType) return providedAuctionType;
|
|
588
|
+
if (dealType === 'GUARANTEED' || dealType === 'PREFERRED_DEAL') return 3;
|
|
589
|
+
if (dealType === 'PRIVATE_AUCTION' || dealType === 'EVERGREEN_PMP') return 1;
|
|
590
|
+
return 1;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
static toSyncPayload(convertedResult) {
|
|
594
|
+
const { deal, lineItems, campaignInventories, insertionOrders, type } = convertedResult;
|
|
595
|
+
const payload = {
|
|
596
|
+
...deal,
|
|
597
|
+
lineItems: lineItems.map(li => ({ ...li, inventories: li.inventories || [] }))
|
|
598
|
+
};
|
|
599
|
+
if (type === PayloadType.DIRECT_NO_LINE_ITEMS) {
|
|
600
|
+
payload.campaignInventories = campaignInventories || [];
|
|
601
|
+
payload.insertionOrders = insertionOrders || [];
|
|
602
|
+
}
|
|
603
|
+
return payload;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
static validateExternalPayload(externalPayload, payloadType) {
|
|
607
|
+
const errors = [];
|
|
608
|
+
if (!externalPayload.campaign) {
|
|
609
|
+
errors.push('campaign object is required');
|
|
610
|
+
} else if (!externalPayload.campaign.name) {
|
|
611
|
+
errors.push('campaign.name is required');
|
|
612
|
+
}
|
|
613
|
+
if (payloadType === PayloadType.DIRECT_PUBLISHER_SPLIT || payloadType === PayloadType.DIRECT_NO_LINE_ITEMS) {
|
|
614
|
+
if (!externalPayload.inventories || !Array.isArray(externalPayload.inventories)) {
|
|
615
|
+
errors.push(`inventories array is required for ${payloadType}`);
|
|
616
|
+
} else if (externalPayload.inventories.length === 0) {
|
|
617
|
+
errors.push(`inventories array cannot be empty for ${payloadType}`);
|
|
618
|
+
} else {
|
|
619
|
+
externalPayload.inventories.forEach((inv, idx) => {
|
|
620
|
+
const hasPubId = (inv.publisher && inv.publisher.id) || inv.publisherId;
|
|
621
|
+
if (!hasPubId) {
|
|
622
|
+
errors.push(`inventories[${idx}] missing publisher ID`);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return { valid: errors.length === 0, errors };
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
export default CampaignImportConverter;
|