@yoryoboy/bi-mcp 1.0.1
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/README.md +346 -0
- package/bin/bi-mcp.js +2 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.js +768 -0
- package/dist/index.js.map +7 -0
- package/dist/mcp-use.json +7 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/icon.svg +6 -0
- package/dist/src/analytics/ga4-channel-groups.js +20 -0
- package/dist/src/analytics/ga4-channel-groups.js.map +7 -0
- package/dist/src/analytics/ga4-report-utils.js +117 -0
- package/dist/src/analytics/ga4-report-utils.js.map +7 -0
- package/dist/src/config/benchmarks.js +128 -0
- package/dist/src/config/benchmarks.js.map +7 -0
- package/dist/src/config/google.js +41 -0
- package/dist/src/config/google.js.map +7 -0
- package/dist/src/config/vtex.js +26 -0
- package/dist/src/config/vtex.js.map +7 -0
- package/dist/src/google-ads/report-utils.js +78 -0
- package/dist/src/google-ads/report-utils.js.map +7 -0
- package/dist/src/prompts/reporte-ventas.js +75 -0
- package/dist/src/prompts/reporte-ventas.js.map +7 -0
- package/dist/src/search-console/search-console-utils.js +275 -0
- package/dist/src/search-console/search-console-utils.js.map +7 -0
- package/dist/src/services/analytics/ga4-client.js +69 -0
- package/dist/src/services/analytics/ga4-client.js.map +7 -0
- package/dist/src/services/analytics/oauth.js +30 -0
- package/dist/src/services/analytics/oauth.js.map +7 -0
- package/dist/src/services/google-ads/google-ads-client.js +54 -0
- package/dist/src/services/google-ads/google-ads-client.js.map +7 -0
- package/dist/src/services/search-console/search-console-client.js +45 -0
- package/dist/src/services/search-console/search-console-client.js.map +7 -0
- package/dist/src/services/vtex/vtex-api.js +51 -0
- package/dist/src/services/vtex/vtex-api.js.map +7 -0
- package/dist/src/services/vtex/vtex-catalog.js +18 -0
- package/dist/src/services/vtex/vtex-catalog.js.map +7 -0
- package/dist/src/services/vtex/vtex-logistics.js +151 -0
- package/dist/src/services/vtex/vtex-logistics.js.map +7 -0
- package/dist/src/services/vtex/vtex-orders.js +143 -0
- package/dist/src/services/vtex/vtex-orders.js.map +7 -0
- package/dist/src/services/vtex/vtex-pricing.js +17 -0
- package/dist/src/services/vtex/vtex-pricing.js.map +7 -0
- package/dist/src/tools/analytics/attribution-gaps.js +109 -0
- package/dist/src/tools/analytics/attribution-gaps.js.map +7 -0
- package/dist/src/tools/analytics/channel-mix.js +74 -0
- package/dist/src/tools/analytics/channel-mix.js.map +7 -0
- package/dist/src/tools/analytics/ecommerce-tracking-health.js +89 -0
- package/dist/src/tools/analytics/ecommerce-tracking-health.js.map +7 -0
- package/dist/src/tools/analytics/engagement-overview.js +71 -0
- package/dist/src/tools/analytics/engagement-overview.js.map +7 -0
- package/dist/src/tools/analytics/index.js +12 -0
- package/dist/src/tools/analytics/index.js.map +7 -0
- package/dist/src/tools/analytics/list-accessible-properties.js +46 -0
- package/dist/src/tools/analytics/list-accessible-properties.js.map +7 -0
- package/dist/src/tools/analytics/property-info.js +54 -0
- package/dist/src/tools/analytics/property-info.js.map +7 -0
- package/dist/src/tools/analytics/revenue-by-channel.js +70 -0
- package/dist/src/tools/analytics/revenue-by-channel.js.map +7 -0
- package/dist/src/tools/analytics/revenue-overview.js +77 -0
- package/dist/src/tools/analytics/revenue-overview.js.map +7 -0
- package/dist/src/tools/analytics/revenue-trend.js +69 -0
- package/dist/src/tools/analytics/revenue-trend.js.map +7 -0
- package/dist/src/tools/analytics/source-medium-breakdown.js +86 -0
- package/dist/src/tools/analytics/source-medium-breakdown.js.map +7 -0
- package/dist/src/tools/analytics/top-landing-pages.js +79 -0
- package/dist/src/tools/analytics/top-landing-pages.js.map +7 -0
- package/dist/src/tools/google-ads/account-overview.js +103 -0
- package/dist/src/tools/google-ads/account-overview.js.map +7 -0
- package/dist/src/tools/google-ads/account-risks.js +267 -0
- package/dist/src/tools/google-ads/account-risks.js.map +7 -0
- package/dist/src/tools/google-ads/break-even-analysis.js +107 -0
- package/dist/src/tools/google-ads/break-even-analysis.js.map +7 -0
- package/dist/src/tools/google-ads/campaign-performance.js +157 -0
- package/dist/src/tools/google-ads/campaign-performance.js.map +7 -0
- package/dist/src/tools/google-ads/channel-mix.js +129 -0
- package/dist/src/tools/google-ads/channel-mix.js.map +7 -0
- package/dist/src/tools/google-ads/compare-accounts.js +122 -0
- package/dist/src/tools/google-ads/compare-accounts.js.map +7 -0
- package/dist/src/tools/google-ads/customer-clients.js +77 -0
- package/dist/src/tools/google-ads/customer-clients.js.map +7 -0
- package/dist/src/tools/google-ads/customer-info.js +64 -0
- package/dist/src/tools/google-ads/customer-info.js.map +7 -0
- package/dist/src/tools/google-ads/index.js +12 -0
- package/dist/src/tools/google-ads/index.js.map +7 -0
- package/dist/src/tools/google-ads/scaling-health.js +174 -0
- package/dist/src/tools/google-ads/scaling-health.js.map +7 -0
- package/dist/src/tools/google-ads/search-terms-summary.js +131 -0
- package/dist/src/tools/google-ads/search-terms-summary.js.map +7 -0
- package/dist/src/tools/google-ads/time-series.js +126 -0
- package/dist/src/tools/google-ads/time-series.js.map +7 -0
- package/dist/src/tools/index.js +5 -0
- package/dist/src/tools/index.js.map +7 -0
- package/dist/src/tools/search-console/country-breakdown.js +85 -0
- package/dist/src/tools/search-console/country-breakdown.js.map +7 -0
- package/dist/src/tools/search-console/device-breakdown.js +85 -0
- package/dist/src/tools/search-console/device-breakdown.js.map +7 -0
- package/dist/src/tools/search-console/high-impression-low-click-queries.js +95 -0
- package/dist/src/tools/search-console/high-impression-low-click-queries.js.map +7 -0
- package/dist/src/tools/search-console/index.js +15 -0
- package/dist/src/tools/search-console/index.js.map +7 -0
- package/dist/src/tools/search-console/list-accessible-sites.js +42 -0
- package/dist/src/tools/search-console/list-accessible-sites.js.map +7 -0
- package/dist/src/tools/search-console/low-ctr-opportunities.js +98 -0
- package/dist/src/tools/search-console/low-ctr-opportunities.js.map +7 -0
- package/dist/src/tools/search-console/page-performance.js +104 -0
- package/dist/src/tools/search-console/page-performance.js.map +7 -0
- package/dist/src/tools/search-console/product-demand-low-capture-queries.js +93 -0
- package/dist/src/tools/search-console/product-demand-low-capture-queries.js.map +7 -0
- package/dist/src/tools/search-console/query-page-matrix.js +99 -0
- package/dist/src/tools/search-console/query-page-matrix.js.map +7 -0
- package/dist/src/tools/search-console/query-performance.js +109 -0
- package/dist/src/tools/search-console/query-performance.js.map +7 -0
- package/dist/src/tools/search-console/quick-win-opportunities.js +93 -0
- package/dist/src/tools/search-console/quick-win-opportunities.js.map +7 -0
- package/dist/src/tools/search-console/rising-non-brand-queries.js +121 -0
- package/dist/src/tools/search-console/rising-non-brand-queries.js.map +7 -0
- package/dist/src/tools/search-console/search-performance.js +89 -0
- package/dist/src/tools/search-console/search-performance.js.map +7 -0
- package/dist/src/tools/search-console/site-context.js +43 -0
- package/dist/src/tools/search-console/site-context.js.map +7 -0
- package/dist/src/tools/search-console/visibility-declines.js +146 -0
- package/dist/src/tools/search-console/visibility-declines.js.map +7 -0
- package/dist/src/tools/vtex/computed-price.js +48 -0
- package/dist/src/tools/vtex/computed-price.js.map +7 -0
- package/dist/src/tools/vtex/index.js +11 -0
- package/dist/src/tools/vtex/index.js.map +7 -0
- package/dist/src/tools/vtex/inventory-check.js +148 -0
- package/dist/src/tools/vtex/inventory-check.js.map +7 -0
- package/dist/src/tools/vtex/order-details.js +56 -0
- package/dist/src/tools/vtex/order-details.js.map +7 -0
- package/dist/src/tools/vtex/orders-summary.js +83 -0
- package/dist/src/tools/vtex/orders-summary.js.map +7 -0
- package/dist/src/tools/vtex/product-offers.js +28 -0
- package/dist/src/tools/vtex/product-offers.js.map +7 -0
- package/dist/src/tools/vtex/sku-offers.js +30 -0
- package/dist/src/tools/vtex/sku-offers.js.map +7 -0
- package/dist/src/tools/vtex/sku-price.js +42 -0
- package/dist/src/tools/vtex/sku-price.js.map +7 -0
- package/dist/src/tools/vtex/update-inventory.js +43 -0
- package/dist/src/tools/vtex/update-inventory.js.map +7 -0
- package/dist/src/tools/vtex/update-lead-time.js +32 -0
- package/dist/src/tools/vtex/update-lead-time.js.map +7 -0
- package/dist/src/tools/vtex/warehouse-inventory.js +42 -0
- package/dist/src/tools/vtex/warehouse-inventory.js.map +7 -0
- package/dist/src/utils/case-conversion.js +21 -0
- package/dist/src/utils/case-conversion.js.map +7 -0
- package/dist/src/utils/currency.js +52 -0
- package/dist/src/utils/currency.js.map +7 -0
- package/dist/src/utils/format-order-details.js +137 -0
- package/dist/src/utils/format-order-details.js.map +7 -0
- package/dist/src/utils/google-ads.js +78 -0
- package/dist/src/utils/google-ads.js.map +7 -0
- package/dist/src/utils/money.js +83 -0
- package/dist/src/utils/money.js.map +7 -0
- package/dist/src/utils/order-status.js +11 -0
- package/dist/src/utils/order-status.js.map +7 -0
- package/dist/src/utils/pagination.js +45 -0
- package/dist/src/utils/pagination.js.map +7 -0
- package/dist/src/utils/strip-payload.js +40 -0
- package/dist/src/utils/strip-payload.js.map +7 -0
- package/dist/src/utils/type-guards.js +7 -0
- package/dist/src/utils/type-guards.js.map +7 -0
- package/package.json +66 -0
- package/public/favicon.ico +0 -0
- package/public/icon.svg +6 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../index.ts"],
|
|
4
|
+
"sourcesContent": ["import { createRequire } from \"node:module\";\nimport { pathToFileURL } from \"node:url\";\nimport { MCPServer } from \"mcp-use/server\";\n\nimport {\n reporteVentasPromptHandler,\n reporteVentasPromptSchema,\n} from \"./src/prompts/reporte-ventas.js\";\nimport { getBenchmarksHandler, getBenchmarksSchema } from \"./src/config/benchmarks.js\";\nimport {\n googleAdsAccountRisksHandler,\n googleAdsAccountRisksSchema,\n googleAdsAccountOverviewHandler,\n googleAdsAccountOverviewSchema,\n googleAdsBreakEvenAnalysisHandler,\n googleAdsBreakEvenAnalysisSchema,\n googleAdsCampaignPerformanceHandler,\n googleAdsCampaignPerformanceSchema,\n googleAdsChannelMixHandler,\n googleAdsChannelMixSchema,\n googleAdsCompareAccountsHandler,\n googleAdsCompareAccountsSchema,\n googleAdsCustomerClientsHandler,\n googleAdsCustomerClientsSchema,\n googleAdsCustomerInfoHandler,\n googleAdsCustomerInfoSchema,\n googleAdsSearchTermsSummaryHandler,\n googleAdsSearchTermsSummarySchema,\n googleAdsScalingHealthHandler,\n googleAdsScalingHealthSchema,\n googleAdsTimeSeriesHandler,\n googleAdsTimeSeriesSchema,\n listAccessibleSitesHandler,\n listAccessibleSitesSchema,\n attributionGapsHandler,\n attributionGapsSchema,\n channelMixHandler,\n channelMixSchema,\n computedPriceHandler,\n computedPriceSchema,\n ecommerceTrackingHealthHandler,\n ecommerceTrackingHealthSchema,\n engagementOverviewHandler,\n engagementOverviewSchema,\n inventoryCheckHandler,\n inventoryCheckSchema,\n listAccessiblePropertiesHandler,\n listAccessiblePropertiesSchema,\n searchConsoleCountryBreakdownHandler,\n searchConsoleCountryBreakdownSchema,\n searchConsoleDeviceBreakdownHandler,\n searchConsoleDeviceBreakdownSchema,\n searchConsoleHighImpressionLowClickQueriesHandler,\n searchConsoleHighImpressionLowClickQueriesSchema,\n searchConsoleLowCtrOpportunitiesHandler,\n searchConsoleLowCtrOpportunitiesSchema,\n searchConsolePagePerformanceHandler,\n searchConsolePagePerformanceSchema,\n searchConsoleProductDemandLowCaptureQueriesHandler,\n searchConsoleProductDemandLowCaptureQueriesSchema,\n searchConsoleQueryPageMatrixHandler,\n searchConsoleQueryPageMatrixSchema,\n searchConsoleQueryPerformanceHandler,\n searchConsoleQueryPerformanceSchema,\n searchConsoleQuickWinOpportunitiesHandler,\n searchConsoleQuickWinOpportunitiesSchema,\n searchConsoleRisingNonBrandQueriesHandler,\n searchConsoleRisingNonBrandQueriesSchema,\n searchConsoleSearchPerformanceHandler,\n searchConsoleSearchPerformanceSchema,\n searchConsoleSiteContextHandler,\n searchConsoleSiteContextSchema,\n searchConsoleVisibilityDeclinesHandler,\n searchConsoleVisibilityDeclinesSchema,\n orderDetailsHandler,\n orderDetailsSchema,\n ordersSummaryHandler,\n ordersSummarySchema,\n propertyInfoHandler,\n propertyInfoSchema,\n productOffersHandler,\n productOffersSchema,\n revenueByChannelHandler,\n revenueByChannelSchema,\n revenueOverviewHandler,\n revenueOverviewSchema,\n revenueTrendHandler,\n revenueTrendSchema,\n skuOffersHandler,\n skuOffersSchema,\n skuPriceHandler,\n skuPriceSchema,\n sourceMediumBreakdownHandler,\n sourceMediumBreakdownSchema,\n topLandingPagesHandler,\n topLandingPagesSchema,\n updateInventoryHandler,\n updateInventorySchema,\n updateLeadTimeHandler,\n updateLeadTimeSchema,\n warehouseInventoryHandler,\n warehouseInventorySchema,\n} from \"./src/tools/index.js\";\n\nconst server = new MCPServer({\n name: \"bi-mcp\",\n title: \"BI MCP\",\n version: \"1.0.0\",\n description: \"Business Intelligence MCP server with VTEX tools and room for additional data sources.\",\n baseUrl: process.env.MCP_URL || \"http://localhost:3000\",\n favicon: \"favicon.ico\",\n icons: [\n {\n src: \"icon.svg\",\n mimeType: \"image/svg+xml\",\n sizes: [\"512x512\"],\n },\n ],\n});\n\nserver.tool(\n {\n name: \"vtex_get_orders_summary\",\n description: \"Get aggregated orders summary by date range with currency-aware BI metrics.\",\n schema: ordersSummarySchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n ordersSummaryHandler\n);\n\nserver.tool(\n {\n name: \"vtex_get_order_details\",\n description: \"Get BI-focused detailed information for one or more orders.\",\n schema: orderDetailsSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n orderDetailsHandler\n);\n\nserver.tool(\n {\n name: \"vtex_check_inventory\",\n description: \"Check global SKU inventory and infer stock health status.\",\n schema: inventoryCheckSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n inventoryCheckHandler\n);\n\nserver.tool(\n {\n name: \"vtex_get_warehouse_inventory\",\n description: \"Get SKU inventory details for a specific warehouse.\",\n schema: warehouseInventorySchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n warehouseInventoryHandler\n);\n\nserver.tool(\n {\n name: \"vtex_update_inventory\",\n description: \"Update SKU inventory quantity or unlimited mode for a warehouse.\",\n schema: updateInventorySchema,\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n openWorldHint: true,\n },\n },\n updateInventoryHandler\n);\n\nserver.tool(\n {\n name: \"vtex_update_lead_time\",\n description: \"Update SKU lead time for a warehouse.\",\n schema: updateLeadTimeSchema,\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n openWorldHint: true,\n },\n },\n updateLeadTimeHandler\n);\n\nserver.tool(\n {\n name: \"vtex_get_sku_price\",\n description: \"Get base pricing information for one SKU.\",\n schema: skuPriceSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n skuPriceHandler\n);\n\nserver.tool(\n {\n name: \"vtex_get_computed_price\",\n description: \"Get computed SKU price by price table context.\",\n schema: computedPriceSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n computedPriceHandler\n);\n\nserver.tool(\n {\n name: \"vtex_get_product_offers\",\n description: \"Get offers for all SKUs under a product.\",\n schema: productOffersSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n productOffersHandler\n);\n\nserver.tool(\n {\n name: \"vtex_get_sku_offers\",\n description: \"Get offers for a specific SKU under a product.\",\n schema: skuOffersSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n skuOffersHandler\n);\n\nserver.tool(\n {\n name: \"config_get_benchmarks\",\n description:\n \"Devuelve benchmarks de Argentina para c\u00E1lculos financieros: IIBB por provincia, costos de cuotas sin inter\u00E9s (Ahora 12, Plan Z), fees de pasarelas de pago (Mercado Pago, Mobbex, Payway, dLocal), costos log\u00EDsticos por zona y calendario comercial con impacto de revenue.\",\n schema: getBenchmarksSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: false,\n },\n },\n getBenchmarksHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_channel_mix\",\n description:\n \"Get Google Ads mix by advertising channel type for a date range, including spend, clicks, impressions, conversions, conversion value, and channel share.\",\n schema: googleAdsChannelMixSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsChannelMixHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_customer_info\",\n description:\n \"Get summary information for one Google Ads customer account, including name, currency, timezone, and whether the account is a manager (MCC).\",\n schema: googleAdsCustomerInfoSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsCustomerInfoHandler\n);\n\nserver.tool(\n {\n name: \"gads_list_customer_clients\",\n description:\n \"List visible child accounts for a Google Ads customer account, usually used to inspect manager (MCC) account structure.\",\n schema: googleAdsCustomerClientsSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsCustomerClientsHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_account_overview\",\n description:\n \"Get a Google Ads account overview for a date range, including spend, clicks, impressions, conversions, conversion value, CTR, CPC, CPA, and ROAS.\",\n schema: googleAdsAccountOverviewSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsAccountOverviewHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_campaign_performance\",\n description:\n \"Get Google Ads campaign-level performance for a date range with spend, clicks, impressions, conversions, conversion value, CTR, CPC, CPA, and ROAS.\",\n schema: googleAdsCampaignPerformanceSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsCampaignPerformanceHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_time_series\",\n description:\n \"Get Google Ads daily or weekly time series for a date range with spend, clicks, impressions, conversions, conversion value, CPA, and ROAS.\",\n schema: googleAdsTimeSeriesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsTimeSeriesHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_search_terms_summary\",\n description:\n \"Get a ranked summary of Google Ads search terms for a date range, including spend, clicks, impressions, conversions, conversion value, CPA, and ROAS.\",\n schema: googleAdsSearchTermsSummarySchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsSearchTermsSummaryHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_account_risks\",\n description:\n \"Evaluate Google Ads account risks for a date range, including concentration, low efficiency, weak conversion volume, and recent deterioration signals.\",\n schema: googleAdsAccountRisksSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsAccountRisksHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_break_even_analysis\",\n description:\n \"Compare current Google Ads performance against a user-provided break-even ROAS and optional CPA target.\",\n schema: googleAdsBreakEvenAnalysisSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsBreakEvenAnalysisHandler\n);\n\nserver.tool(\n {\n name: \"gads_get_scaling_health\",\n description:\n \"Assess whether a Google Ads account is ready to scale using break-even ROAS, optional CPA target, concentration, stability, and conversion volume.\",\n schema: googleAdsScalingHealthSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsScalingHealthHandler\n);\n\nserver.tool(\n {\n name: \"gads_compare_accounts\",\n description:\n \"Compare multiple Google Ads accounts across the same date range and rank them by basic risk and efficiency signals.\",\n schema: googleAdsCompareAccountsSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n googleAdsCompareAccountsHandler\n);\n\nserver.tool(\n {\n name: \"gsc_list_accessible_sites\",\n description: \"List all Search Console sites accessible with the configured Google credentials.\",\n schema: listAccessibleSitesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n listAccessibleSitesHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_site_context\",\n description: \"Validate one Search Console site and return the resolved site context used by the module.\",\n schema: searchConsoleSiteContextSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleSiteContextHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_search_performance\",\n description: \"Run a flexible Search Console performance query with custom dimensions and filters.\",\n schema: searchConsoleSearchPerformanceSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleSearchPerformanceHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_query_performance\",\n description: \"Get Search Console performance grouped by search query for a date range.\",\n schema: searchConsoleQueryPerformanceSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleQueryPerformanceHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_page_performance\",\n description: \"Get Search Console performance grouped by landing page for a date range.\",\n schema: searchConsolePagePerformanceSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsolePagePerformanceHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_query_page_matrix\",\n description: \"Get a Search Console matrix crossing queries and landing pages for a date range.\",\n schema: searchConsoleQueryPageMatrixSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleQueryPageMatrixHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_device_breakdown\",\n description: \"Break down Search Console performance by device for a date range.\",\n schema: searchConsoleDeviceBreakdownSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleDeviceBreakdownHandler\n);\n\nserver.tool(\n {\n name: \"gsc_get_country_breakdown\",\n description: \"Break down Search Console performance by country for a date range.\",\n schema: searchConsoleCountryBreakdownSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleCountryBreakdownHandler\n);\n\nserver.tool(\n {\n name: \"gsc_find_high_impression_low_click_queries\",\n description: \"Find queries with high Search Console impression volume but weak click capture.\",\n schema: searchConsoleHighImpressionLowClickQueriesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleHighImpressionLowClickQueriesHandler\n);\n\nserver.tool(\n {\n name: \"gsc_find_low_ctr_opportunities\",\n description: \"Find Search Console queries that rank reasonably well but underperform on CTR.\",\n schema: searchConsoleLowCtrOpportunitiesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleLowCtrOpportunitiesHandler\n);\n\nserver.tool(\n {\n name: \"gsc_detect_visibility_declines\",\n description: \"Detect Search Console pages that are losing visibility between two periods.\",\n schema: searchConsoleVisibilityDeclinesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleVisibilityDeclinesHandler\n);\n\nserver.tool(\n {\n name: \"gsc_find_product_demand_low_capture_queries\",\n description: \"Find product-intent queries with demand in Search Console but weak click capture.\",\n schema: searchConsoleProductDemandLowCaptureQueriesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleProductDemandLowCaptureQueriesHandler\n);\n\nserver.tool(\n {\n name: \"gsc_find_rising_non_brand_queries\",\n description: \"Find non-branded Search Console queries growing between two periods.\",\n schema: searchConsoleRisingNonBrandQueriesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleRisingNonBrandQueriesHandler\n);\n\nserver.tool(\n {\n name: \"gsc_find_quick_win_opportunities\",\n description: \"Prioritize Search Console quick wins across CTR improvements and ranking gains.\",\n schema: searchConsoleQuickWinOpportunitiesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n searchConsoleQuickWinOpportunitiesHandler\n);\n\nserver.tool(\n {\n name: \"ga4_list_accessible_properties\",\n description: \"List all Google Analytics 4 accounts and properties accessible with the configured OAuth credentials.\",\n schema: listAccessiblePropertiesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n listAccessiblePropertiesHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_property_info\",\n description: \"Get summary information and capabilities for one GA4 property, including ecommerce and attribution support.\",\n schema: propertyInfoSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n propertyInfoHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_channel_mix\",\n description: \"Get traffic mix by default channel group with shares of sessions and users for a date range.\",\n schema: channelMixSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n channelMixHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_source_medium_breakdown\",\n description: \"Get traffic breakdown by session source / medium with session and user share for a date range.\",\n schema: sourceMediumBreakdownSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n sourceMediumBreakdownHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_revenue_overview\",\n description: \"Get GA4 ecommerce overview for a date range including transactions, revenue, purchasers, and rates.\",\n schema: revenueOverviewSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n revenueOverviewHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_revenue_trend\",\n description: \"Get daily GA4 revenue and transactions trend for a date range.\",\n schema: revenueTrendSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n revenueTrendHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_revenue_by_channel\",\n description: \"Get GA4 revenue and transactions by default channel group for a date range.\",\n schema: revenueByChannelSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n revenueByChannelHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_top_landing_pages\",\n description: \"Get top landing pages by sessions and users for a date range.\",\n schema: topLandingPagesSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n topLandingPagesHandler\n);\n\nserver.tool(\n {\n name: \"ga4_get_engagement_overview\",\n description: \"Get GA4 engagement metrics for a date range, including engagement rate, bounce rate, and session duration.\",\n schema: engagementOverviewSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n engagementOverviewHandler\n);\n\nserver.tool(\n {\n name: \"ga4_detect_attribution_gaps\",\n description: \"Detect unattributed traffic, unassigned channels, and not-set source / medium values in GA4.\",\n schema: attributionGapsSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n attributionGapsHandler\n);\n\nserver.tool(\n {\n name: \"ga4_check_ecommerce_tracking_health\",\n description: \"Evaluate whether GA4 ecommerce tracking appears complete by checking item views, carts, checkouts, purchases, and refunds.\",\n schema: ecommerceTrackingHealthSchema,\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: true,\n },\n },\n ecommerceTrackingHealthHandler\n);\n\nserver.prompt(\n {\n name: \"vtex-reporte-ventas\",\n description:\n \"Genera un prompt de reporte de ventas VTEX usando una sola entrada temporal en lenguaje natural.\",\n schema: reporteVentasPromptSchema,\n },\n reporteVentasPromptHandler\n);\n\nasync function createStdioTransportFromMcpUseDependency() {\n const requireFromHere = createRequire(import.meta.url);\n const mcpUseServerEntry = requireFromHere.resolve(\"mcp-use/server\");\n const requireFromMcpUse = createRequire(mcpUseServerEntry);\n const stdioModulePath = requireFromMcpUse.resolve(\"@modelcontextprotocol/sdk/server/stdio.js\");\n const stdioModule = (await import(pathToFileURL(stdioModulePath).href)) as {\n StdioServerTransport: new () => unknown;\n };\n\n return new stdioModule.StdioServerTransport();\n}\n\nasync function startServer() {\n const transport = (process.env.MCP_TRANSPORT ?? \"http\").trim().toLowerCase();\n\n if (transport === \"stdio\") {\n const stdioTransport = await createStdioTransportFromMcpUseDependency();\n await server.nativeServer.connect(stdioTransport as any);\n console.error(\"MCP server running on stdio transport\");\n return;\n }\n\n if (transport === \"http\") {\n const port = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 3000;\n if (Number.isNaN(port)) {\n throw new Error(`Invalid PORT value: ${process.env.PORT}`);\n }\n\n console.error(`MCP server running on http transport (port ${port})`);\n await server.listen(port);\n return;\n }\n\n throw new Error(`Invalid MCP_TRANSPORT \"${process.env.MCP_TRANSPORT}\". Use \"http\" or \"stdio\".`);\n}\n\nstartServer().catch((error) => {\n console.error(\"Failed to start MCP server\", error);\n process.exit(1);\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAE1B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB,2BAA2B;AAC1D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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QAAM,aAAa,QAAQ,IAAI,iBAAiB,QAAQ,KAAK,EAAE,YAAY;AAE3E,MAAI,cAAc,SAAS;AACzB,UAAM,iBAAiB,MAAM,yCAAyC;AACtE,UAAM,OAAO,aAAa,QAAQ,cAAqB;AACvD,YAAQ,MAAM,uCAAuC;AACrD;AAAA,EACF;AAEA,MAAI,cAAc,QAAQ;AACxB,UAAM,OAAO,QAAQ,IAAI,OAAO,OAAO,SAAS,QAAQ,IAAI,MAAM,EAAE,IAAI;AACxE,QAAI,OAAO,MAAM,IAAI,GAAG;AACtB,YAAM,IAAI,MAAM,uBAAuB,QAAQ,IAAI,IAAI,EAAE;AAAA,IAC3D;AAEA,YAAQ,MAAM,8CAA8C,IAAI,GAAG;AACnE,UAAM,OAAO,OAAO,IAAI;AACxB;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,0BAA0B,QAAQ,IAAI,aAAa,2BAA2B;AAChG;AAEA,YAAY,EAAE,MAAM,CAAC,UAAU;AAC7B,UAAQ,MAAM,8BAA8B,KAAK;AACjD,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="1000" height="1000" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="1000" height="1000" rx="500" fill="black"/>
|
|
3
|
+
<path d="M355.933 250C414.437 250 461.865 297.607 461.865 356.333C461.865 381.829 460.493 408.403 471.068 431.602L478.975 448.947C493.584 480.997 519.265 506.7 551.303 521.336L566.155 528.121C590.142 539.079 617.694 537.335 644.066 537.335C702.571 537.335 749.999 584.942 749.999 643.668C749.999 702.394 702.571 750.001 644.066 750.001C585.562 750.001 538.134 702.394 538.134 643.668C538.134 618.974 539.24 593.275 528.992 570.807L520.586 552.38C505.948 520.29 480.214 494.565 448.118 479.939L430.164 471.758C407.282 461.331 381.078 462.666 355.933 462.666C297.428 462.666 250 415.059 250 356.333C250 297.607 297.428 250 355.933 250Z" fill="white"/>
|
|
4
|
+
<circle cx="350.426" cy="649.575" r="100.426" fill="white"/>
|
|
5
|
+
<path d="M750 350.426C750 405.889 705.037 450.851 649.574 450.851C594.11 450.851 549.148 405.889 549.148 350.426C549.148 294.962 594.11 250 649.574 250C705.037 250 750 294.962 750 350.426Z" fill="white"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const PAID_DEFAULT_CHANNEL_GROUPS = [
|
|
2
|
+
"Audio",
|
|
3
|
+
"Cross-network",
|
|
4
|
+
"Display",
|
|
5
|
+
"Paid Other",
|
|
6
|
+
"Paid Search",
|
|
7
|
+
"Paid Shopping",
|
|
8
|
+
"Paid Social",
|
|
9
|
+
"Paid Video"
|
|
10
|
+
];
|
|
11
|
+
function isPaidDefaultChannelGroup(channel) {
|
|
12
|
+
return PAID_DEFAULT_CHANNEL_GROUPS.includes(
|
|
13
|
+
channel
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
PAID_DEFAULT_CHANNEL_GROUPS,
|
|
18
|
+
isPaidDefaultChannelGroup
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=ga4-channel-groups.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/analytics/ga4-channel-groups.ts"],
|
|
4
|
+
"sourcesContent": ["export const PAID_DEFAULT_CHANNEL_GROUPS = [\n \"Audio\",\n \"Cross-network\",\n \"Display\",\n \"Paid Other\",\n \"Paid Search\",\n \"Paid Shopping\",\n \"Paid Social\",\n \"Paid Video\",\n] as const;\n\nexport function isPaidDefaultChannelGroup(channel: string): boolean {\n return PAID_DEFAULT_CHANNEL_GROUPS.includes(\n channel as (typeof PAID_DEFAULT_CHANNEL_GROUPS)[number]\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,8BAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,0BAA0B,SAA0B;AAClE,SAAO,4BAA4B;AAAA,IACjC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getDefaultGa4PropertyId } from "../config/google.js";
|
|
2
|
+
function resolveGa4PropertyId(propertyId) {
|
|
3
|
+
const explicitPropertyId = propertyId?.trim();
|
|
4
|
+
if (explicitPropertyId) {
|
|
5
|
+
return explicitPropertyId;
|
|
6
|
+
}
|
|
7
|
+
const defaultPropertyId = getDefaultGa4PropertyId();
|
|
8
|
+
if (defaultPropertyId) {
|
|
9
|
+
return defaultPropertyId;
|
|
10
|
+
}
|
|
11
|
+
throw new Error("Missing GA4 property ID. Provide propertyId or configure GA4_PROPERTY_ID.");
|
|
12
|
+
}
|
|
13
|
+
function parseMetricValue(value) {
|
|
14
|
+
if (!value) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
const parsedValue = Number(value);
|
|
18
|
+
return Number.isFinite(parsedValue) ? parsedValue : 0;
|
|
19
|
+
}
|
|
20
|
+
function getMetricValueByName(row, metricHeaders, metricName) {
|
|
21
|
+
const metricIndex = metricHeaders?.findIndex((metric) => metric.name === metricName) ?? -1;
|
|
22
|
+
if (metricIndex < 0) {
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
return parseMetricValue(row.metricValues?.[metricIndex]?.value);
|
|
26
|
+
}
|
|
27
|
+
function getDimensionValue(row, index = 0) {
|
|
28
|
+
return row.dimensionValues?.[index]?.value ?? "";
|
|
29
|
+
}
|
|
30
|
+
function toPercent(numerator, denominator) {
|
|
31
|
+
if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator <= 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
return numerator / denominator * 100;
|
|
35
|
+
}
|
|
36
|
+
function round(value, decimals = 2) {
|
|
37
|
+
if (!Number.isFinite(value)) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
const factor = 10 ** decimals;
|
|
41
|
+
return Math.round(value * factor) / factor;
|
|
42
|
+
}
|
|
43
|
+
function formatGa4Date(value) {
|
|
44
|
+
if (!/^\d{8}$/.test(value)) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}`;
|
|
48
|
+
}
|
|
49
|
+
function findPropertySummary(accountSummaries, propertyId) {
|
|
50
|
+
for (const account of accountSummaries) {
|
|
51
|
+
for (const property of account.propertySummaries ?? []) {
|
|
52
|
+
if (property.property === `properties/${propertyId}`) {
|
|
53
|
+
return {
|
|
54
|
+
accountId: account.account.replace("accounts/", ""),
|
|
55
|
+
accountName: account.displayName,
|
|
56
|
+
propertyId,
|
|
57
|
+
propertyName: property.displayName,
|
|
58
|
+
propertyType: property.propertyType
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
function detectSeverity(sharePercent) {
|
|
66
|
+
if (sharePercent >= 10) {
|
|
67
|
+
return "high";
|
|
68
|
+
}
|
|
69
|
+
if (sharePercent >= 3) {
|
|
70
|
+
return "medium";
|
|
71
|
+
}
|
|
72
|
+
return "low";
|
|
73
|
+
}
|
|
74
|
+
function isProblematicAttributionValue(value) {
|
|
75
|
+
const normalizedValue = value.toLowerCase();
|
|
76
|
+
return normalizedValue.includes("(not set)") || normalizedValue.includes("(data not available)") || normalizedValue.includes("unassigned");
|
|
77
|
+
}
|
|
78
|
+
function sumMetricValues(rows, metricHeaders, metricName) {
|
|
79
|
+
return (rows ?? []).reduce((total, row) => {
|
|
80
|
+
return total + getMetricValueByName(row, metricHeaders, metricName);
|
|
81
|
+
}, 0);
|
|
82
|
+
}
|
|
83
|
+
function extractQuotaSnapshot(report) {
|
|
84
|
+
const quota = report.propertyQuota;
|
|
85
|
+
if (!quota) {
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
tokens_per_day_remaining: quota.tokensPerDay?.remaining ?? 0,
|
|
90
|
+
tokens_per_hour_remaining: quota.tokensPerHour?.remaining ?? 0,
|
|
91
|
+
concurrent_requests_remaining: quota.concurrentRequests?.remaining ?? 0,
|
|
92
|
+
tokens_per_project_per_hour_remaining: quota.tokensPerProjectPerHour?.remaining ?? 0
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function findMetricHeader(metricHeaders, metricName) {
|
|
96
|
+
return metricHeaders?.find((metric) => metric.name === metricName);
|
|
97
|
+
}
|
|
98
|
+
function getFirstMetricValue(metricValues, index) {
|
|
99
|
+
return parseMetricValue(metricValues?.[index]?.value);
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
detectSeverity,
|
|
103
|
+
extractQuotaSnapshot,
|
|
104
|
+
findMetricHeader,
|
|
105
|
+
findPropertySummary,
|
|
106
|
+
formatGa4Date,
|
|
107
|
+
getDimensionValue,
|
|
108
|
+
getFirstMetricValue,
|
|
109
|
+
getMetricValueByName,
|
|
110
|
+
isProblematicAttributionValue,
|
|
111
|
+
parseMetricValue,
|
|
112
|
+
resolveGa4PropertyId,
|
|
113
|
+
round,
|
|
114
|
+
sumMetricValues,
|
|
115
|
+
toPercent
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=ga4-report-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/analytics/ga4-report-utils.ts"],
|
|
4
|
+
"sourcesContent": ["import { getDefaultGa4PropertyId } from \"../config/google.js\";\nimport type {\n Ga4AccountSummary,\n Ga4MetricHeader,\n Ga4MetricValue,\n Ga4ReportResponse,\n Ga4ReportRow,\n} from \"../services/analytics/ga4-client.js\";\n\nexport function resolveGa4PropertyId(propertyId?: string): string {\n const explicitPropertyId = propertyId?.trim();\n if (explicitPropertyId) {\n return explicitPropertyId;\n }\n\n const defaultPropertyId = getDefaultGa4PropertyId();\n if (defaultPropertyId) {\n return defaultPropertyId;\n }\n\n throw new Error(\"Missing GA4 property ID. Provide propertyId or configure GA4_PROPERTY_ID.\");\n}\n\nexport function parseMetricValue(value: string | undefined): number {\n if (!value) {\n return 0;\n }\n\n const parsedValue = Number(value);\n return Number.isFinite(parsedValue) ? parsedValue : 0;\n}\n\nexport function getMetricValueByName(\n row: Ga4ReportRow,\n metricHeaders: Ga4MetricHeader[] | undefined,\n metricName: string\n): number {\n const metricIndex = metricHeaders?.findIndex((metric) => metric.name === metricName) ?? -1;\n if (metricIndex < 0) {\n return 0;\n }\n\n return parseMetricValue(row.metricValues?.[metricIndex]?.value);\n}\n\nexport function getDimensionValue(row: Ga4ReportRow, index = 0): string {\n return row.dimensionValues?.[index]?.value ?? \"\";\n}\n\nexport function toPercent(numerator: number, denominator: number): number {\n if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator <= 0) {\n return 0;\n }\n\n return (numerator / denominator) * 100;\n}\n\nexport function round(value: number, decimals = 2): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n const factor = 10 ** decimals;\n return Math.round(value * factor) / factor;\n}\n\nexport function formatGa4Date(value: string): string {\n if (!/^\\d{8}$/.test(value)) {\n return value;\n }\n\n return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}`;\n}\n\nexport function findPropertySummary(\n accountSummaries: Ga4AccountSummary[],\n propertyId: string\n): {\n accountId: string;\n accountName: string;\n propertyId: string;\n propertyName: string;\n propertyType?: string;\n} | undefined {\n for (const account of accountSummaries) {\n for (const property of account.propertySummaries ?? []) {\n if (property.property === `properties/${propertyId}`) {\n return {\n accountId: account.account.replace(\"accounts/\", \"\"),\n accountName: account.displayName,\n propertyId,\n propertyName: property.displayName,\n propertyType: property.propertyType,\n };\n }\n }\n }\n\n return undefined;\n}\n\nexport function detectSeverity(sharePercent: number): \"low\" | \"medium\" | \"high\" {\n if (sharePercent >= 10) {\n return \"high\";\n }\n\n if (sharePercent >= 3) {\n return \"medium\";\n }\n\n return \"low\";\n}\n\nexport function isProblematicAttributionValue(value: string): boolean {\n const normalizedValue = value.toLowerCase();\n\n return (\n normalizedValue.includes(\"(not set)\") ||\n normalizedValue.includes(\"(data not available)\") ||\n normalizedValue.includes(\"unassigned\")\n );\n}\n\nexport function sumMetricValues(\n rows: Ga4ReportRow[] | undefined,\n metricHeaders: Ga4MetricHeader[] | undefined,\n metricName: string\n): number {\n return (rows ?? []).reduce((total, row) => {\n return total + getMetricValueByName(row, metricHeaders, metricName);\n }, 0);\n}\n\nexport function extractQuotaSnapshot(report: Ga4ReportResponse): Record<string, number> | undefined {\n const quota = report.propertyQuota;\n if (!quota) {\n return undefined;\n }\n\n return {\n tokens_per_day_remaining: quota.tokensPerDay?.remaining ?? 0,\n tokens_per_hour_remaining: quota.tokensPerHour?.remaining ?? 0,\n concurrent_requests_remaining: quota.concurrentRequests?.remaining ?? 0,\n tokens_per_project_per_hour_remaining: quota.tokensPerProjectPerHour?.remaining ?? 0,\n };\n}\n\nexport function findMetricHeader(\n metricHeaders: Ga4MetricHeader[] | undefined,\n metricName: string\n): Ga4MetricHeader | undefined {\n return metricHeaders?.find((metric) => metric.name === metricName);\n}\n\nexport function getFirstMetricValue(\n metricValues: Ga4MetricValue[] | undefined,\n index: number\n): number {\n return parseMetricValue(metricValues?.[index]?.value);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,+BAA+B;AASjC,SAAS,qBAAqB,YAA6B;AAChE,QAAM,qBAAqB,YAAY,KAAK;AAC5C,MAAI,oBAAoB;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,wBAAwB;AAClD,MAAI,mBAAmB;AACrB,WAAO;AAAA,EACT;AAEA,QAAM,IAAI,MAAM,2EAA2E;AAC7F;AAEO,SAA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AAAA,UACrB;AAAA,UACA,cAAc,SAAS;AAAA,UACvB,cAAc,SAAS;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,eAAe,cAAiD;AAC9E,MAAI,gBAAgB,IAAI;AACtB,WAAO;AAAA,EACT;AAEA,MAAI,gBAAgB,GAAG;AACrB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,8BAA8B,OAAwB;AACpE,QAAM,kBAAkB,MAAM,YAAY;AAE1C,SACE,gBAAgB,SAAS,WAAW,KACpC,gBAAgB,SAAS,sBAAsB,KAC/C,gBAAgB,SAAS,YAAY;AAEzC;AAEO,SAAS,gBACd,MACA,eACA,YACQ;AACR,UAAQ,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,QAAQ;AACzC,WAAO,QAAQ,qBAAqB,KAAK,eAAe,UAAU;AAAA,EACpE,GAAG,CAAC;AACN;AAEO,SAAS,qBAAqB,QAA+D;AAClG,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,0BAA0B,MAAM,cAAc,aAAa;AAAA,IAC3D,2BAA2B,MAAM,eAAe,aAAa;AAAA,IAC7D,+BAA+B,MAAM,oBAAoB,aAAa;AAAA,IACtE,uCAAuC,MAAM,yBAAyB,aAAa;AAAA,EACrF;AACF;AAEO,SAAS,iBACd,eACA,YAC6B;AAC7B,SAAO,eAAe,KAAK,CAAC,WAAW,OAAO,SAAS,UAAU;AACnE;AAEO,SAAS,oBACd,cACA,OACQ;AACR,SAAO,iBAAiB,eAAe,KAAK,GAAG,KAAK;AACtD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { object } from "mcp-use/server";
|
|
3
|
+
const IIBB_BY_PROVINCE = {
|
|
4
|
+
CABA: { general: 3, simplificado: 1.5, retencionesBancarias: 2.5 },
|
|
5
|
+
"Buenos Aires": { general: 3.5, simplificado: 2, retencionesBancarias: 3 },
|
|
6
|
+
C\u00F3rdoba: { general: 4, simplificado: 2.5, retencionesBancarias: 2 },
|
|
7
|
+
"Santa Fe": { general: 3.5, simplificado: 2, retencionesBancarias: 2.5 },
|
|
8
|
+
Mendoza: { general: 4, simplificado: 2.5, retencionesBancarias: 2 },
|
|
9
|
+
"Interior (promedio)": { general: 3.5, simplificado: 2, retencionesBancarias: 2 }
|
|
10
|
+
};
|
|
11
|
+
const INSTALLMENT_COSTS = {
|
|
12
|
+
"3": { ahora12: 7, propio: 8, planZ: 6 },
|
|
13
|
+
// 3 MSI
|
|
14
|
+
"6": { ahora12: 11.5, propio: 13.5, planZ: 10 },
|
|
15
|
+
// 6 MSI
|
|
16
|
+
"12": { ahora12: 18, propio: 22.5, planZ: 16.5 },
|
|
17
|
+
// 12 MSI
|
|
18
|
+
"18": { ahora12: 25, propio: null, planZ: 22 }
|
|
19
|
+
// 18 MSI (Propio: N/A)
|
|
20
|
+
};
|
|
21
|
+
const PAYMENT_GATEWAY_FEES = {
|
|
22
|
+
mercado_pago: {
|
|
23
|
+
feeMin: 4.5,
|
|
24
|
+
feeMax: 5.5,
|
|
25
|
+
feeMid: 5,
|
|
26
|
+
ivaMultiplier: 1.21,
|
|
27
|
+
liquidacionDiasMin: 14,
|
|
28
|
+
liquidacionDiasMax: 21
|
|
29
|
+
},
|
|
30
|
+
mobbex: {
|
|
31
|
+
feeMin: 2.8,
|
|
32
|
+
feeMax: 3.5,
|
|
33
|
+
feeMid: 3.15,
|
|
34
|
+
ivaMultiplier: 1.21,
|
|
35
|
+
liquidacionDiasMin: 7,
|
|
36
|
+
liquidacionDiasMax: 14
|
|
37
|
+
},
|
|
38
|
+
payway: {
|
|
39
|
+
feeMin: 2.5,
|
|
40
|
+
feeMax: 3.2,
|
|
41
|
+
feeMid: 2.85,
|
|
42
|
+
ivaMultiplier: 1.21,
|
|
43
|
+
liquidacionDiasMin: 7,
|
|
44
|
+
liquidacionDiasMax: 10
|
|
45
|
+
},
|
|
46
|
+
dlocal_go: {
|
|
47
|
+
feeMin: 3,
|
|
48
|
+
feeMax: 4,
|
|
49
|
+
feeMid: 3.5,
|
|
50
|
+
ivaMultiplier: 1.21,
|
|
51
|
+
liquidacionDiasMin: 10,
|
|
52
|
+
liquidacionDiasMax: 14
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const LOGISTICS_COSTS = {
|
|
56
|
+
CABA: { estandarMin: 4e3, estandarMax: 6e3, expressMin: 6e3, expressMax: 9e3, pesoLimiteKg: 5 },
|
|
57
|
+
GBA: { estandarMin: 5e3, estandarMax: 8e3, expressMin: 8e3, expressMax: 12e3, pesoLimiteKg: 5 },
|
|
58
|
+
"Interior Cercano": { estandarMin: 7e3, estandarMax: 12e3, expressMin: 15e3, expressMax: 2e4, pesoLimiteKg: 5 },
|
|
59
|
+
"Interior Lejano": { estandarMin: 12e3, estandarMax: 2e4, expressMin: 25e3, expressMax: 35e3, pesoLimiteKg: 5 },
|
|
60
|
+
Patagonia: { estandarMin: 18e3, estandarMax: 3e4, expressMin: 35e3, expressMax: 5e4, pesoLimiteKg: 5 }
|
|
61
|
+
};
|
|
62
|
+
const COMMERCIAL_CALENDAR = [
|
|
63
|
+
{ evento: "Hot Sale", mes: 5, impactoRevenueMin: 200, impactoRevenueMax: 500, preparacionDias: 60, esTemporadaBaja: false },
|
|
64
|
+
{ evento: "CyberMonday", mes: 11, impactoRevenueMin: 200, impactoRevenueMax: 400, preparacionDias: 45, esTemporadaBaja: false },
|
|
65
|
+
{ evento: "D\xEDa de la Madre", mes: 10, impactoRevenueMin: 100, impactoRevenueMax: 200, preparacionDias: 30, esTemporadaBaja: false },
|
|
66
|
+
{ evento: "Navidad", mes: 12, impactoRevenueMin: 150, impactoRevenueMax: 300, preparacionDias: 45, esTemporadaBaja: false },
|
|
67
|
+
{ evento: "D\xEDa del Padre", mes: 6, impactoRevenueMin: 50, impactoRevenueMax: 100, preparacionDias: 20, esTemporadaBaja: false },
|
|
68
|
+
{ evento: "D\xEDa del Ni\xF1o", mes: 8, impactoRevenueMin: 50, impactoRevenueMax: 150, preparacionDias: 20, esTemporadaBaja: false },
|
|
69
|
+
{ evento: "Temporada Baja", mes: 1, impactoRevenueMin: -50, impactoRevenueMax: -30, preparacionDias: 0, esTemporadaBaja: true },
|
|
70
|
+
{ evento: "Temporada Baja", mes: 2, impactoRevenueMin: -50, impactoRevenueMax: -30, preparacionDias: 0, esTemporadaBaja: true }
|
|
71
|
+
];
|
|
72
|
+
const getBenchmarksSchema = z.object({
|
|
73
|
+
type: z.enum(["iibb", "installments", "payment_gateways", "logistics", "calendar", "all"]).describe(
|
|
74
|
+
"Tipo de benchmark a consultar. 'iibb' = al\xEDcuotas de Ingresos Brutos por provincia. 'installments' = costo de cuotas sin inter\xE9s (Ahora 12, Plan Z, etc.). 'payment_gateways' = fees de pasarelas de pago (Mercado Pago, Mobbex, etc.). 'logistics' = costos de env\xEDo de referencia por zona. 'calendar' = calendario comercial Argentina con impacto de revenue. 'all' = devuelve todos los benchmarks."
|
|
75
|
+
)
|
|
76
|
+
});
|
|
77
|
+
async function getBenchmarksHandler(params) {
|
|
78
|
+
switch (params.type) {
|
|
79
|
+
case "iibb":
|
|
80
|
+
return object({
|
|
81
|
+
type: "iibb",
|
|
82
|
+
description: "Al\xEDcuotas de Ingresos Brutos por provincia (porcentajes sobre venta neta)",
|
|
83
|
+
data: IIBB_BY_PROVINCE
|
|
84
|
+
});
|
|
85
|
+
case "installments":
|
|
86
|
+
return object({
|
|
87
|
+
type: "installments",
|
|
88
|
+
description: "Costo financiero de cuotas sin inter\xE9s. Valores son porcentajes sobre el monto de venta. 'propio' para 18 cuotas es N/A.",
|
|
89
|
+
data: INSTALLMENT_COSTS
|
|
90
|
+
});
|
|
91
|
+
case "payment_gateways":
|
|
92
|
+
return object({
|
|
93
|
+
type: "payment_gateways",
|
|
94
|
+
description: "Fees de pasarelas de pago. Los fees NO incluyen IVA \u2014 multiplicar por ivaMultiplier (1.21) para el costo real.",
|
|
95
|
+
data: PAYMENT_GATEWAY_FEES
|
|
96
|
+
});
|
|
97
|
+
case "logistics":
|
|
98
|
+
return object({
|
|
99
|
+
type: "logistics",
|
|
100
|
+
description: "Costos log\xEDsticos de referencia en ARS. Actualizar seg\xFAn inflaci\xF3n vigente.",
|
|
101
|
+
data: LOGISTICS_COSTS
|
|
102
|
+
});
|
|
103
|
+
case "calendar":
|
|
104
|
+
return object({
|
|
105
|
+
type: "calendar",
|
|
106
|
+
description: "Calendario comercial Argentina. impactoRevenue es porcentaje adicional sobre d\xEDas normales.",
|
|
107
|
+
data: COMMERCIAL_CALENDAR
|
|
108
|
+
});
|
|
109
|
+
case "all":
|
|
110
|
+
return object({
|
|
111
|
+
iibb: IIBB_BY_PROVINCE,
|
|
112
|
+
installments: INSTALLMENT_COSTS,
|
|
113
|
+
paymentGateways: PAYMENT_GATEWAY_FEES,
|
|
114
|
+
logistics: LOGISTICS_COSTS,
|
|
115
|
+
calendar: COMMERCIAL_CALENDAR
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
COMMERCIAL_CALENDAR,
|
|
121
|
+
IIBB_BY_PROVINCE,
|
|
122
|
+
INSTALLMENT_COSTS,
|
|
123
|
+
LOGISTICS_COSTS,
|
|
124
|
+
PAYMENT_GATEWAY_FEES,
|
|
125
|
+
getBenchmarksHandler,
|
|
126
|
+
getBenchmarksSchema
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=benchmarks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/benchmarks.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\nimport { object } from \"mcp-use/server\";\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// BENCHMARKS DE ARGENTINA\n// Fuente: Ecommerce Growth & Profit OS \u2013 Argentina Edition (V3.5)\n// Secci\u00F3n: \uD83C\uDDE6\uD83C\uDDF7 CONTEXTO ARGENTINA\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n// IIBB por provincia\n// Porcentajes expresados como n\u00FAmeros (ej: 3.0 = 3.0%)\nexport const IIBB_BY_PROVINCE: Record<\n string,\n { general: number; simplificado: number; retencionesBancarias: number }\n> = {\n CABA: { general: 3.0, simplificado: 1.5, retencionesBancarias: 2.5 },\n \"Buenos Aires\": { general: 3.5, simplificado: 2.0, retencionesBancarias: 3.0 },\n C\u00F3rdoba: { general: 4.0, simplificado: 2.5, retencionesBancarias: 2.0 },\n \"Santa Fe\": { general: 3.5, simplificado: 2.0, retencionesBancarias: 2.5 },\n Mendoza: { general: 4.0, simplificado: 2.5, retencionesBancarias: 2.0 },\n \"Interior (promedio)\": { general: 3.5, simplificado: 2.0, retencionesBancarias: 2.0 },\n};\n\n// Costos de financiaci\u00F3n en cuotas sin inter\u00E9s\n// Porcentajes expresados como n\u00FAmeros (ej: 7.0 = 7.0%)\n// Rangos representados como valor medio de referencia\nexport const INSTALLMENT_COSTS: Record<\n string,\n { ahora12: number; propio: number; planZ: number }\n> = {\n \"3\": { ahora12: 7.0, propio: 8.0, planZ: 6.0 }, // 3 MSI\n \"6\": { ahora12: 11.5, propio: 13.5, planZ: 10.0 }, // 6 MSI\n \"12\": { ahora12: 18.0, propio: 22.5, planZ: 16.5 }, // 12 MSI\n \"18\": { ahora12: 25.0, propio: null as unknown as number, planZ: 22.0 }, // 18 MSI (Propio: N/A)\n};\n\n// Fees de pasarelas de pago\n// fee: porcentaje de transacci\u00F3n (valor medio del rango, sin IVA)\n// ivaMultiplier: multiplicador para aplicar IVA (1.21 = 21% IVA)\n// liquidacionDias: rango de d\u00EDas de liquidaci\u00F3n\nexport const PAYMENT_GATEWAY_FEES: Record<\n string,\n { feeMin: number; feeMax: number; feeMid: number; ivaMultiplier: number; liquidacionDiasMin: number; liquidacionDiasMax: number }\n> = {\n mercado_pago: {\n feeMin: 4.5,\n feeMax: 5.5,\n feeMid: 5.0,\n ivaMultiplier: 1.21,\n liquidacionDiasMin: 14,\n liquidacionDiasMax: 21,\n },\n mobbex: {\n feeMin: 2.8,\n feeMax: 3.5,\n feeMid: 3.15,\n ivaMultiplier: 1.21,\n liquidacionDiasMin: 7,\n liquidacionDiasMax: 14,\n },\n payway: {\n feeMin: 2.5,\n feeMax: 3.2,\n feeMid: 2.85,\n ivaMultiplier: 1.21,\n liquidacionDiasMin: 7,\n liquidacionDiasMax: 10,\n },\n dlocal_go: {\n feeMin: 3.0,\n feeMax: 4.0,\n feeMid: 3.5,\n ivaMultiplier: 1.21,\n liquidacionDiasMin: 10,\n liquidacionDiasMax: 14,\n },\n};\n\n// Costos log\u00EDsticos de referencia (ARS, rangos)\n// Valores al momento de publicaci\u00F3n del prompt de Juli\u00E1n \u2014 actualizar seg\u00FAn inflaci\u00F3n\nexport const LOGISTICS_COSTS: Record<\n string,\n { estandarMin: number; estandarMax: number; expressMin: number; expressMax: number; pesoLimiteKg: number }\n> = {\n CABA: { estandarMin: 4000, estandarMax: 6000, expressMin: 6000, expressMax: 9000, pesoLimiteKg: 5 },\n GBA: { estandarMin: 5000, estandarMax: 8000, expressMin: 8000, expressMax: 12000, pesoLimiteKg: 5 },\n \"Interior Cercano\": { estandarMin: 7000, estandarMax: 12000, expressMin: 15000, expressMax: 20000, pesoLimiteKg: 5 },\n \"Interior Lejano\": { estandarMin: 12000, estandarMax: 20000, expressMin: 25000, expressMax: 35000, pesoLimiteKg: 5 },\n Patagonia: { estandarMin: 18000, estandarMax: 30000, expressMin: 35000, expressMax: 50000, pesoLimiteKg: 5 },\n};\n\n// Calendario comercial Argentina \u2014 impacto revenue respecto a d\u00EDas normales\nexport const COMMERCIAL_CALENDAR: Array<{\n evento: string;\n mes: number; // 1-12\n impactoRevenueMin: number; // porcentaje adicional (200 = +200%)\n impactoRevenueMax: number;\n preparacionDias: number;\n esTemporadaBaja: boolean;\n}> = [\n { evento: \"Hot Sale\", mes: 5, impactoRevenueMin: 200, impactoRevenueMax: 500, preparacionDias: 60, esTemporadaBaja: false },\n { evento: \"CyberMonday\", mes: 11, impactoRevenueMin: 200, impactoRevenueMax: 400, preparacionDias: 45, esTemporadaBaja: false },\n { evento: \"D\u00EDa de la Madre\", mes: 10, impactoRevenueMin: 100, impactoRevenueMax: 200, preparacionDias: 30, esTemporadaBaja: false },\n { evento: \"Navidad\", mes: 12, impactoRevenueMin: 150, impactoRevenueMax: 300, preparacionDias: 45, esTemporadaBaja: false },\n { evento: \"D\u00EDa del Padre\", mes: 6, impactoRevenueMin: 50, impactoRevenueMax: 100, preparacionDias: 20, esTemporadaBaja: false },\n { evento: \"D\u00EDa del Ni\u00F1o\", mes: 8, impactoRevenueMin: 50, impactoRevenueMax: 150, preparacionDias: 20, esTemporadaBaja: false },\n { evento: \"Temporada Baja\", mes: 1, impactoRevenueMin: -50, impactoRevenueMax: -30, preparacionDias: 0, esTemporadaBaja: true },\n { evento: \"Temporada Baja\", mes: 2, impactoRevenueMin: -50, impactoRevenueMax: -30, preparacionDias: 0, esTemporadaBaja: true },\n];\n\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// TOOL: config_get_benchmarks\n// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const getBenchmarksSchema = z.object({\n type: z\n .enum([\"iibb\", \"installments\", \"payment_gateways\", \"logistics\", \"calendar\", \"all\"])\n .describe(\n \"Tipo de benchmark a consultar. \" +\n \"'iibb' = al\u00EDcuotas de Ingresos Brutos por provincia. \" +\n \"'installments' = costo de cuotas sin inter\u00E9s (Ahora 12, Plan Z, etc.). \" +\n \"'payment_gateways' = fees de pasarelas de pago (Mercado Pago, Mobbex, etc.). \" +\n \"'logistics' = costos de env\u00EDo de referencia por zona. \" +\n \"'calendar' = calendario comercial Argentina con impacto de revenue. \" +\n \"'all' = devuelve todos los benchmarks.\"\n ),\n});\n\nexport async function getBenchmarksHandler(\n params: z.infer<typeof getBenchmarksSchema>\n) {\n switch (params.type) {\n case \"iibb\":\n return object({\n type: \"iibb\",\n description: \"Al\u00EDcuotas de Ingresos Brutos por provincia (porcentajes sobre venta neta)\",\n data: IIBB_BY_PROVINCE,\n });\n\n case \"installments\":\n return object({\n type: \"installments\",\n description: \"Costo financiero de cuotas sin inter\u00E9s. Valores son porcentajes sobre el monto de venta. 'propio' para 18 cuotas es N/A.\",\n data: INSTALLMENT_COSTS,\n });\n\n case \"payment_gateways\":\n return object({\n type: \"payment_gateways\",\n description: \"Fees de pasarelas de pago. Los fees NO incluyen IVA \u2014 multiplicar por ivaMultiplier (1.21) para el costo real.\",\n data: PAYMENT_GATEWAY_FEES,\n });\n\n case \"logistics\":\n return object({\n type: \"logistics\",\n description: \"Costos log\u00EDsticos de referencia en ARS. Actualizar seg\u00FAn inflaci\u00F3n vigente.\",\n data: LOGISTICS_COSTS,\n });\n\n case \"calendar\":\n return object({\n type: \"calendar\",\n description: \"Calendario comercial Argentina. impactoRevenue es porcentaje adicional sobre d\u00EDas normales.\",\n data: COMMERCIAL_CALENDAR,\n });\n\n case \"all\":\n return object({\n iibb: IIBB_BY_PROVINCE,\n installments: INSTALLMENT_COSTS,\n paymentGateways: PAYMENT_GATEWAY_FEES,\n logistics: LOGISTICS_COSTS,\n calendar: COMMERCIAL_CALENDAR,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,cAAc;AAUhB,MAAM,mBAGT;AAAA,EACF,MAAM,EAAE,SAAS,GAAK,cAAc,KAAK,sBAAsB,IAAI;AAAA,EACnE,gBAAgB,EAAE,SAAS,KAAK,cAAc,GAAK,sBAAsB,EAAI;AAAA,EAC7E,cAAS,EAAE,SAAS,GAAK,cAAc,KAAK,s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AAQ,gBAAgB,oBAAoB,aAAa,YAAY,KAAK,CAAC,EACjF;AAAA,IACC;AAAA,EAOF;AACJ,CAAC;AAED,eAAsB,qBACpB,QACA;AACA,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,QACN,aAAa;AAAA,QACb,MAAM;AAAA,MACR,CAAC;AAAA,IAEH,KAAK;AACH,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,QACN,aAAa;AAAA,QACb,MAAM;AAAA,MACR,CAAC;AAAA,IAEH,KAAK;AACH,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,QACN,aAAa;AAAA,QACb,MAAM;AAAA,MACR,CAAC;AAAA,IAEH,KAAK;AACH,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,QACN,aAAa;AAAA,QACb,MAAM;AAAA,MACR,CAAC;AAAA,IAEH,KAAK;AACH,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,QACN,aAAa;AAAA,QACb,MAAM;AAAA,MACR,CAAC;AAAA,IAEH,KAAK;AACH,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,QACN,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,WAAW;AAAA,QACX,UAAU;AAAA,MACZ,CAAC;AAAA,EACL;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const REQUIRED_ENV_VARS = [
|
|
2
|
+
"GOOGLE_OAUTH_CLIENT_ID",
|
|
3
|
+
"GOOGLE_OAUTH_CLIENT_SECRET",
|
|
4
|
+
"GOOGLE_OAUTH_REFRESH_TOKEN"
|
|
5
|
+
];
|
|
6
|
+
function requireEnv(name) {
|
|
7
|
+
const value = process.env[name]?.trim();
|
|
8
|
+
if (!value) {
|
|
9
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
const googleOAuthConfig = {
|
|
14
|
+
clientId: requireEnv("GOOGLE_OAUTH_CLIENT_ID"),
|
|
15
|
+
clientSecret: requireEnv("GOOGLE_OAUTH_CLIENT_SECRET"),
|
|
16
|
+
refreshToken: requireEnv("GOOGLE_OAUTH_REFRESH_TOKEN")
|
|
17
|
+
};
|
|
18
|
+
function getDefaultGa4PropertyId() {
|
|
19
|
+
const value = process.env.GA4_PROPERTY_ID?.trim();
|
|
20
|
+
return value ? value : void 0;
|
|
21
|
+
}
|
|
22
|
+
function getGoogleAdsDeveloperToken() {
|
|
23
|
+
const value = process.env.GOOGLE_ADS_DEVELOPER_TOKEN?.trim();
|
|
24
|
+
if (!value) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"Missing Google Ads developer token. Configure GOOGLE_ADS_DEVELOPER_TOKEN."
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
function getDefaultGoogleAdsLoginCustomerId() {
|
|
32
|
+
const value = process.env.GOOGLE_ADS_LOGIN_CUSTOMER_ID?.trim();
|
|
33
|
+
return value ? value.replace(/-/g, "") : void 0;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
getDefaultGa4PropertyId,
|
|
37
|
+
getDefaultGoogleAdsLoginCustomerId,
|
|
38
|
+
getGoogleAdsDeveloperToken,
|
|
39
|
+
googleOAuthConfig
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=google.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/google.ts"],
|
|
4
|
+
"sourcesContent": ["const REQUIRED_ENV_VARS = [\n \"GOOGLE_OAUTH_CLIENT_ID\",\n \"GOOGLE_OAUTH_CLIENT_SECRET\",\n \"GOOGLE_OAUTH_REFRESH_TOKEN\",\n] as const;\n\ntype RequiredEnvVar = (typeof REQUIRED_ENV_VARS)[number];\n\nfunction requireEnv(name: RequiredEnvVar): string {\n const value = process.env[name]?.trim();\n if (!value) {\n throw new Error(`Missing required environment variable: ${name}`);\n }\n\n return value;\n}\n\nexport interface GoogleOAuthConfig {\n clientId: string;\n clientSecret: string;\n refreshToken: string;\n}\n\nexport const googleOAuthConfig: GoogleOAuthConfig = {\n clientId: requireEnv(\"GOOGLE_OAUTH_CLIENT_ID\"),\n clientSecret: requireEnv(\"GOOGLE_OAUTH_CLIENT_SECRET\"),\n refreshToken: requireEnv(\"GOOGLE_OAUTH_REFRESH_TOKEN\"),\n};\n\nexport function getDefaultGa4PropertyId(): string | undefined {\n const value = process.env.GA4_PROPERTY_ID?.trim();\n return value ? value : undefined;\n}\n\nexport function getGoogleAdsDeveloperToken(): string {\n const value = process.env.GOOGLE_ADS_DEVELOPER_TOKEN?.trim();\n if (!value) {\n throw new Error(\n \"Missing Google Ads developer token. Configure GOOGLE_ADS_DEVELOPER_TOKEN.\"\n );\n }\n\n return value;\n}\n\nexport function getDefaultGoogleAdsLoginCustomerId(): string | undefined {\n const value = process.env.GOOGLE_ADS_LOGIN_CUSTOMER_ID?.trim();\n return value ? value.replace(/-/g, \"\") : undefined;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF;AAIA,SAAS,WAAW,MAA8B;AAChD,QAAM,QAAQ,QAAQ,IAAI,IAAI,GAAG,KAAK;AACtC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0CAA0C,IAAI,EAAE;AAAA,EAClE;AAEA,SAAO;AACT;AAQO,MAAM,oBAAuC;AAAA,EAClD,UAAU,WAAW,wBAAwB;AAAA,EAC7C,cAAc,WAAW,4BAA4B;AAAA,EACrD,cAAc,WAAW,4BAA4B;AACvD;AAEO,SAAS,0BAA8C;AAC5D,QAAM,QAAQ,QAAQ,IAAI,iBAAiB,KAAK;AAChD,SAAO,QAAQ,QAAQ;AACzB;AAEO,SAAS,6BAAqC;AACnD,QAAM,QAAQ,QAAQ,IAAI,4BAA4B,KAAK;AAC3D,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,qCAAyD;AACvE,QAAM,QAAQ,QAAQ,IAAI,8BAA8B,KAAK;AAC7D,SAAO,QAAQ,MAAM,QAAQ,MAAM,EAAE,IAAI;AAC3C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const REQUIRED_ENV_VARS = [
|
|
2
|
+
"VTEX_ACCOUNT_NAME",
|
|
3
|
+
"VTEX_API_KEY",
|
|
4
|
+
"VTEX_API_TOKEN"
|
|
5
|
+
];
|
|
6
|
+
function requireEnv(name) {
|
|
7
|
+
const value = process.env[name]?.trim();
|
|
8
|
+
if (!value) {
|
|
9
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
const accountName = requireEnv("VTEX_ACCOUNT_NAME");
|
|
14
|
+
const apiKey = requireEnv("VTEX_API_KEY");
|
|
15
|
+
const apiToken = requireEnv("VTEX_API_TOKEN");
|
|
16
|
+
const vtexConfig = {
|
|
17
|
+
accountName,
|
|
18
|
+
apiKey,
|
|
19
|
+
apiToken,
|
|
20
|
+
baseUrl: `https://${accountName}.vtexcommercestable.com.br`,
|
|
21
|
+
pricingBaseUrl: `https://api.vtex.com/${accountName}`
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
vtexConfig
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=vtex.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/vtex.ts"],
|
|
4
|
+
"sourcesContent": ["const REQUIRED_ENV_VARS = [\n \"VTEX_ACCOUNT_NAME\",\n \"VTEX_API_KEY\",\n \"VTEX_API_TOKEN\",\n] as const;\n\ntype RequiredEnvVar = (typeof REQUIRED_ENV_VARS)[number];\n\nfunction requireEnv(name: RequiredEnvVar): string {\n const value = process.env[name]?.trim();\n if (!value) {\n throw new Error(`Missing required environment variable: ${name}`);\n }\n return value;\n}\n\nconst accountName = requireEnv(\"VTEX_ACCOUNT_NAME\");\nconst apiKey = requireEnv(\"VTEX_API_KEY\");\nconst apiToken = requireEnv(\"VTEX_API_TOKEN\");\n\nexport interface VtexConfig {\n accountName: string;\n apiKey: string;\n apiToken: string;\n baseUrl: string;\n pricingBaseUrl: string;\n}\n\nexport const vtexConfig: VtexConfig = {\n accountName,\n apiKey,\n apiToken,\n baseUrl: `https://${accountName}.vtexcommercestable.com.br`,\n pricingBaseUrl: `https://api.vtex.com/${accountName}`,\n};\n"],
|
|
5
|
+
"mappings": "AAAA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF;AAIA,SAAS,WAAW,MAA8B;AAChD,QAAM,QAAQ,QAAQ,IAAI,IAAI,GAAG,KAAK;AACtC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0CAA0C,IAAI,EAAE;AAAA,EAClE;AACA,SAAO;AACT;AAEA,MAAM,cAAc,WAAW,mBAAmB;AAClD,MAAM,SAAS,WAAW,cAAc;AACxC,MAAM,WAAW,WAAW,gBAAgB;AAUrC,MAAM,aAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,WAAW,WAAW;AAAA,EAC/B,gBAAgB,wBAAwB,WAAW;AACrD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDefaultGoogleAdsLoginCustomerId,
|
|
3
|
+
getGoogleAdsDeveloperToken
|
|
4
|
+
} from "../config/google.js";
|
|
5
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
6
|
+
function normalizeCustomerId(customerId) {
|
|
7
|
+
const normalized = customerId.trim().replace(/-/g, "");
|
|
8
|
+
if (!/^\d+$/.test(normalized)) {
|
|
9
|
+
throw new Error("Invalid Google Ads customer ID. Use digits only, with or without hyphens.");
|
|
10
|
+
}
|
|
11
|
+
return normalized;
|
|
12
|
+
}
|
|
13
|
+
function resolveGoogleAdsCustomerId(customerId) {
|
|
14
|
+
if (!customerId?.trim()) {
|
|
15
|
+
throw new Error("Missing Google Ads customer ID. Provide customerId.");
|
|
16
|
+
}
|
|
17
|
+
return normalizeCustomerId(customerId);
|
|
18
|
+
}
|
|
19
|
+
function resolveGoogleAdsLoginCustomerId(loginCustomerId) {
|
|
20
|
+
const explicitCustomerId = loginCustomerId?.trim();
|
|
21
|
+
if (explicitCustomerId) {
|
|
22
|
+
return normalizeCustomerId(explicitCustomerId);
|
|
23
|
+
}
|
|
24
|
+
return getDefaultGoogleAdsLoginCustomerId();
|
|
25
|
+
}
|
|
26
|
+
function resolveGoogleAdsDeveloperToken() {
|
|
27
|
+
return getGoogleAdsDeveloperToken();
|
|
28
|
+
}
|
|
29
|
+
function parseGoogleAdsMetricValue(value) {
|
|
30
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "string") {
|
|
34
|
+
const parsedValue = Number(value);
|
|
35
|
+
return Number.isFinite(parsedValue) ? parsedValue : 0;
|
|
36
|
+
}
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
function microsToCurrency(value, decimals = 2) {
|
|
40
|
+
return round(parseGoogleAdsMetricValue(value) / 1e6, decimals);
|
|
41
|
+
}
|
|
42
|
+
function round(value, decimals = 2) {
|
|
43
|
+
if (!Number.isFinite(value)) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const factor = 10 ** decimals;
|
|
47
|
+
return Math.round(value * factor) / factor;
|
|
48
|
+
}
|
|
49
|
+
function toPercent(numerator, denominator) {
|
|
50
|
+
if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator <= 0) {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
return numerator / denominator * 100;
|
|
54
|
+
}
|
|
55
|
+
function getFieldValue(row, path, fallback) {
|
|
56
|
+
const segments = path.split(".");
|
|
57
|
+
let current = row;
|
|
58
|
+
for (const segment of segments) {
|
|
59
|
+
if (!current || typeof current !== "object") {
|
|
60
|
+
return fallback;
|
|
61
|
+
}
|
|
62
|
+
current = current[segment];
|
|
63
|
+
}
|
|
64
|
+
return current ?? fallback;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
dateRegex,
|
|
68
|
+
getFieldValue,
|
|
69
|
+
microsToCurrency,
|
|
70
|
+
normalizeCustomerId,
|
|
71
|
+
parseGoogleAdsMetricValue,
|
|
72
|
+
resolveGoogleAdsCustomerId,
|
|
73
|
+
resolveGoogleAdsDeveloperToken,
|
|
74
|
+
resolveGoogleAdsLoginCustomerId,
|
|
75
|
+
round,
|
|
76
|
+
toPercent
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=report-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/google-ads/report-utils.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n getDefaultGoogleAdsLoginCustomerId,\n getGoogleAdsDeveloperToken,\n} from \"../config/google.js\";\nimport type { GoogleAdsMetricValue, GoogleAdsSearchRow } from \"../services/google-ads/google-ads-client.js\";\n\nexport const dateRegex = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport function normalizeCustomerId(customerId: string): string {\n const normalized = customerId.trim().replace(/-/g, \"\");\n if (!/^\\d+$/.test(normalized)) {\n throw new Error(\"Invalid Google Ads customer ID. Use digits only, with or without hyphens.\");\n }\n\n return normalized;\n}\n\nexport function resolveGoogleAdsCustomerId(customerId?: string): string {\n if (!customerId?.trim()) {\n throw new Error(\"Missing Google Ads customer ID. Provide customerId.\");\n }\n\n return normalizeCustomerId(customerId);\n}\n\nexport function resolveGoogleAdsLoginCustomerId(loginCustomerId?: string): string | undefined {\n const explicitCustomerId = loginCustomerId?.trim();\n if (explicitCustomerId) {\n return normalizeCustomerId(explicitCustomerId);\n }\n\n return getDefaultGoogleAdsLoginCustomerId();\n}\n\nexport function resolveGoogleAdsDeveloperToken(): string {\n return getGoogleAdsDeveloperToken();\n}\n\nexport function parseGoogleAdsMetricValue(value: GoogleAdsMetricValue | undefined): number {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value === \"string\") {\n const parsedValue = Number(value);\n return Number.isFinite(parsedValue) ? parsedValue : 0;\n }\n\n return 0;\n}\n\nexport function microsToCurrency(value: GoogleAdsMetricValue | undefined, decimals = 2): number {\n return round(parseGoogleAdsMetricValue(value) / 1_000_000, decimals);\n}\n\nexport function round(value: number, decimals = 2): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n const factor = 10 ** decimals;\n return Math.round(value * factor) / factor;\n}\n\nexport function toPercent(numerator: number, denominator: number): number {\n if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator <= 0) {\n return 0;\n }\n\n return (numerator / denominator) * 100;\n}\n\nexport function getFieldValue<T>(row: GoogleAdsSearchRow, path: string, fallback?: T): T | undefined {\n const segments = path.split(\".\");\n let current: unknown = row;\n\n for (const segment of segments) {\n if (!current || typeof current !== \"object\") {\n return fallback;\n }\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n return (current as T | undefined) ?? fallback;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAGA,MAAM,YAAY;AAElB,SAAS,oBAAoB,YAA4B;AAC9D,QAAM,aAAa,WAAW,KAAK,EAAE,QAAQ,MAAM,EAAE;AACrD,MAAI,CAAC,QAAQ,KAAK,UAAU,GAAG;AAC7B,UAAM,IAAI,MAAM,2EAA2E;AAAA,EAC7F;AAEA,SAAO;AACT;AAEO,SAAS,2BAA2B,YAA6B;AACtE,MAA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