#!/usr/bin/env node import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { DISPLAY_CHROME_PATH, DISPLAY_META_PATH, DISPLAY_RUNTIME_HOME, DISPLAY_PROFILE_DIR, DISPLAY_STATE_PATH, ensureParentDir, ensureRuntimeTree, resolveMetaReadPath, resolveRuntimeHome, resolveStateReadPath, } from "./lib/runtime-paths.mjs"; import { parseArgs, splitCsv } from "./lib/cli-shared.mjs"; import { quoteLiteral, toSqlList } from "./lib/sql-literals.mjs"; import { SA_ATTACH_DEFAULT_ALL_STATUSES, SA_ATTACH_DEFAULT_CLUSTER, SA_ATTACH_DEFAULT_MIN_OPPORTUNITY_PROBABILITY, SA_ATTACH_DEFAULT_OPEN_STATUSES, SA_ATTACH_DEFAULT_PRODUCT_LOBS, SA_ATTACH_DEFAULT_REVENUE_TYPE_GROUPS, SA_ATTACH_DEFAULT_SALES_CREDIT_TYPE, SA_ATTACH_DEFAULT_SOLUTIONS, SA_ATTACH_DEFAULT_WON_STATUSES, applyCloseWindowIntentDefaults, applyCurrentWorkloadIntentDefaults, resolveCommercialClusterFilter, resolveCoverageLimit, resolveManagerEmailFilter, resolveManagerEmailListFilter, resolveOptionalClusterFilter, resolveOwnerEmailFilter, resolveResourceFilter, resolveSaAttachFilters, } from "./lib/sa-attach-filters.mjs"; import { cookieHeaderFor, extractClientBin, extractCsrfToken, inferRuntimeHome, isAuthRefreshRequiredError, mergeCookiesFromHeader, normalizeCookie, persistSessionArtifacts, readJson, replaceObjectContents, } from "./lib/auth-shared.mjs"; import { hasAnyDateWindowArgs, resolveDateWindow, resolveQuarterInput, } from "./lib/date-windows.mjs"; import { buildApiMetrics, buildWarnings, emitJson, mapRows, } from "./lib/output-contract.mjs"; import { buildSrCoverageKey, hasUsableOpportunityId, summarizeCurrentTeamOpportunityCoverage, summarizeOrgWideRevenueLineCoverage, } from "./lib/coverage-summary.mjs"; const DEFAULT_BASE_URL = "https://salesintelligence-dv.oracle.com"; const DEFAULT_WORKBOOK_URL = "https://salesintelligence-dv.oracle.com/ui/dv/ui/project.jsp?pageid=visualAnalyzer&reportmode=presentation&reportpath=%2F%40Catalog%2Fshared%2FTeam%20Sharing%20Area%2FLAD%2FLAD%20Sales%20Operations%2FLAD%20Production%2FLAD%20Knowledge%20One%20View"; const SQL_ENDPOINT = "/ui/dv/ui/api/v1/sqlquery/execute"; const SESSION_INFO_ENDPOINT = "/ui/dv/ui/api/v1/sessioninfo/ext"; const NULL_SENTINEL = "__CODEX_NULL__"; const VARCHAR_SIZE = 512; const FISCAL_YEAR_CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000; const SESSION_CONTEXT_CACHE_MAX_AGE_MS = 6 * 60 * 60 * 1000; const SA_ATTACH_OPPORTUNITIES_DATASET = `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Opportunities - V2')`; const SA_ATTACH_HOURS_DATASET = `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Hours - V2')`; const SA_ATTACH_PRESALES_AUX_DATASET = `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Presales Involvement Aux - V1')`; const SA_ATTACH_REVENUE_LINES_DATASET = `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')`; const SOURCE_OPPORTUNITIES = "Knowledge DV - Opportunities - V2"; const SOURCE_HOURS = "Knowledge DV - Hours - V2"; const SOURCE_PRESALES_AUX = "Knowledge DV - Presales Involvement Aux - V1"; const SOURCE_REVENUE_LINES = "Knowledge DV - Revn Lines by SE"; const SOURCE_DV_SE_TEAM = "DV - SE Team"; const SCOPE_AUTO = "auto"; const SCOPE_ORG_WIDE = "org-wide"; const SCOPE_MY_TEAM = "my-team-only"; const SCOPE_MIXED = "mixed-consistent"; const SCOPE_UNKNOWN = "unknown"; const BACKEND_ORG_WIDE = "org-wide"; const BACKEND_ORG_WIDE_CAPABLE = "org-wide-capable"; const BACKEND_MY_TEAM_ONLY = "my-team-only"; const DATASET_REGISTRY = { [SOURCE_OPPORTUNITIES]: { sourceName: SOURCE_OPPORTUNITIES, subjectArea: SA_ATTACH_OPPORTUNITIES_DATASET, backendCapability: BACKEND_ORG_WIDE, defaultScope: SCOPE_ORG_WIDE, allowedScopes: [SCOPE_ORG_WIDE], }, [SOURCE_HOURS]: { sourceName: SOURCE_HOURS, subjectArea: SA_ATTACH_HOURS_DATASET, backendCapability: BACKEND_ORG_WIDE_CAPABLE, defaultScope: SCOPE_ORG_WIDE, allowedScopes: [SCOPE_ORG_WIDE, SCOPE_MY_TEAM], }, [SOURCE_PRESALES_AUX]: { sourceName: SOURCE_PRESALES_AUX, subjectArea: SA_ATTACH_PRESALES_AUX_DATASET, backendCapability: BACKEND_ORG_WIDE_CAPABLE, defaultScope: SCOPE_ORG_WIDE, allowedScopes: [SCOPE_ORG_WIDE, SCOPE_MY_TEAM], }, [SOURCE_REVENUE_LINES]: { sourceName: SOURCE_REVENUE_LINES, subjectArea: SA_ATTACH_REVENUE_LINES_DATASET, backendCapability: BACKEND_ORG_WIDE_CAPABLE, defaultScope: SCOPE_ORG_WIDE, allowedScopes: [SCOPE_ORG_WIDE, SCOPE_MY_TEAM], }, [SOURCE_DV_SE_TEAM]: { sourceName: SOURCE_DV_SE_TEAM, subjectArea: `"${SOURCE_DV_SE_TEAM}"`, backendCapability: BACKEND_MY_TEAM_ONLY, defaultScope: SCOPE_MY_TEAM, allowedScopes: [SCOPE_MY_TEAM], }, }; const VIEW_SCOPE_REGISTRY = { "current-fiscal-year": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, "data-quality-session-context": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, "effort-by-se-team": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, "effort-task-type-summary": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, "opportunities-close-window": { sourceName: SOURCE_OPPORTUNITIES }, "opportunity-details": { sourceName: SOURCE_OPPORTUNITIES }, "revenue-line-details": { sourceName: SOURCE_REVENUE_LINES }, "sa-attach-hours-by-opportunity": { sourceName: SOURCE_HOURS }, "sa-attach-involvement-distribution": { sourceName: SOURCE_OPPORTUNITIES }, "sa-attach-open-pipeline": { sourceName: SOURCE_OPPORTUNITIES }, "sa-attach-pipeline-details": { sourceName: SOURCE_OPPORTUNITIES }, "sa-attach-presales-coverage": { sourceName: SOURCE_PRESALES_AUX }, "sa-attach-won-pipeline": { sourceName: SOURCE_OPPORTUNITIES }, "sr-details": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, "srs-by-resource-email": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, "won-and-open-by-se-opty": { sourceName: SOURCE_DV_SE_TEAM, requiresMyTeam: true }, }; const OPPORTUNITY_DETAILS_COLUMNS = [ { name: "opportunityId", expr: '"Opportunity"."Opportunity ID"', kind: "text" }, { name: "opportunityHours", expr: '"Effort"."# Opportunity Hours"', kind: "scalar" }, { name: "opportunityStatus", expr: '"Opportunity"."Status"', kind: "text" }, { name: "workloadAmount", expr: '"Opportunity"."Workload Amount"', kind: "scalar" }, { name: "registryId", expr: '"Customer"."Registry ID"', kind: "text" }, { name: "customerName", expr: '"Customer"."Customer Name"', kind: "text" }, { name: "dealQualification", expr: '"Opportunity"."Deal Qualification"', kind: "text" }, { name: "forecastTypeGroup", expr: '"Opportunity"."Forecast Type Group"', kind: "text" }, { name: "bookingValue", expr: '"Opportunity"."Opportunity Value"', kind: "scalar" }, { name: "optyCloseFiscalQuarter", expr: '"Time (Close Date Opportunity)"."Opty Close Fiscal Quarter"', kind: "text" }, { name: "sesWithEffort", expr: '"Effort"."# SEs With Effort"', kind: "scalar" }, { name: "serviceRequestsWithEffort", expr: '"Effort"."# Service Requests with Effort"', kind: "scalar" }, { name: "country", expr: '"Customer"."Country"', kind: "text" }, { name: "salesStage", expr: '"Opportunity"."Sales Stage"', kind: "text" }, ]; const SR_DETAILS_COLUMNS = [ { name: "opportunityId", expr: '"Opportunity"."Opportunity ID"', kind: "text" }, { name: "opportunityStatus", expr: '"Opportunity"."Status"', kind: "text" }, { name: "workloadAmount", expr: '"Opportunity"."Workload Amount"', kind: "scalar" }, { name: "registryId", expr: '"Customer"."Registry ID"', kind: "text" }, { name: "customerName", expr: '"Customer"."Customer Name"', kind: "text" }, { name: "bookingValue", expr: '"Opportunity"."Opportunity Value"', kind: "scalar" }, { name: "sesWithEffort", expr: '"Effort"."# SEs With Effort"', kind: "scalar" }, { name: "serviceRequestsWithEffort", expr: '"Effort"."# Service Requests with Effort"', kind: "scalar" }, { name: "srSource", expr: '"Service Request"."SR Source"', kind: "text" }, { name: "srStatus", expr: '"Service Request"."Status"', kind: "text" }, { name: "country", expr: '"Customer"."Country"', kind: "text" }, { name: "hoursExcludingTimeOff", expr: '"Effort"."# Hours (Excl. Time Off)"', kind: "scalar" }, { name: "srNumber", expr: '"Service Request"."SR Number"', kind: "text" }, { name: "createSrDay", expr: '"Time (Create Date Service Request)"."Create SR Day"', kind: "scalar" }, { name: "lastEffort", expr: '"Service Request"."Last Effort"', kind: "scalar" }, { name: "leadEmail", expr: '"Service Request"."Lead Email"', kind: "text" }, { name: "customerDeadline", expr: '"Service Request"."Customer Deadline"', kind: "scalar" }, { name: "primaryPillar", expr: '"Service Request"."Primary Pillar"', kind: "text" }, { name: "opportunityName", expr: '"Opportunity"."Opportunity Name"', kind: "text" }, { name: "totalSrHours", expr: '"Service Request"."Total SR Hours"', kind: "scalar" }, { name: "title", expr: '"Service Request"."Title"', kind: "text" }, { name: "queueName", expr: '"Service Request"."Queue Name"', kind: "text" }, { name: "srRequesterEmailAddress", expr: '"SR Requester"."SR Requester Email Address"', kind: "text" }, { name: "closeSrDay", expr: '"Time (Close Date Service Request)"."Close SR Day"', kind: "scalar" }, ]; const WON_AND_OPEN_COLUMNS = [ { name: "opportunityId", expr: '"Opportunity"."Opportunity ID"', kind: "text" }, { name: "customerName", expr: '"Customer"."Customer Name"', kind: "text" }, { name: "opportunityName", expr: '"Opportunity"."Opportunity Name"', kind: "text" }, { name: "optyCloseFiscalQuarter", expr: '"Time (Close Date Opportunity)"."Opty Close Fiscal Quarter"', kind: "text" }, { name: "optyCloseFiscalMonth", expr: '"Time (Close Date Opportunity)"."Opty Close Fiscal Month"', kind: "text" }, { name: "workloadAmount", expr: '"Opportunity"."Workload Amount"', kind: "scalar" }, { name: "seTeamLevel2EmailAddress", expr: '"SR Team"."SE Team Level 2 Email Address"', kind: "text" }, { name: "opportunityHours", expr: '"Effort"."# Opportunity Hours"', kind: "scalar" }, { name: "hoursContribution", expr: '"Effort"."# Opportunity Hours" / (SUM("Effort"."# Opportunity Hours" BY "Opportunity"."Opportunity ID"))', kind: "scalar", }, { name: "dealContribution", expr: '"Effort"."Deal Contribution"', kind: "scalar" }, ]; const REVENUE_LINE_COLUMNS = [ { name: "revenueLineId", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Line ID"`, kind: "text", }, { name: "opportunityId", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Opportunity ID"`, kind: "text", }, { name: "customerNameOriginal", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Customer Name (Original)"`, kind: "text", }, { name: "registryId", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Registry Id"`, kind: "text", }, { name: "solution", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Solution"`, kind: "text", }, { name: "revenueLineStatus", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Line Status"`, kind: "text", }, { name: "revenueTypeGroup", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Type Group"`, kind: "text", }, { name: "executiveProductLob", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Executive Product Lob"`, kind: "text", }, { name: "pipelineAmount", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Pipeline"`, kind: "scalar", }, { name: "revenueLineCloseYear", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Line Close Year"`, kind: "text", }, { name: "revenueLineCloseQuarter", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Line Close Quarter"`, kind: "text", }, { name: "revenueLineCloseMonth", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Line Close Month"`, kind: "text", }, { name: "revenueLineCloseDate", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Revenue Line Close Date"`, kind: "scalar", }, { name: "seTeamLevel2EmailAddress", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."SE Team Level 2 Email Address"`, kind: "text", }, { name: "cluster", expr: `XSA('ANNA.DE.MAURO@ORACLE.COM'.'Knowledge DV - Revn Lines by SE')."Columns"."Cluster"`, kind: "text", }, ]; const DATA_QUALITY_CONTEXT_COLUMNS = [ { name: "securityEntryPoint", expr: '"Security"."Entry Point"', kind: "text" }, { name: "currentFiscalYear", expr: "valueof(RV_CURR_FISCAL_YEAR)", kind: "text" }, { name: "currentFiscalWeek", expr: "valueof(RV_CURR_FISCAL_WEEK)", kind: "text" }, { name: "previousFiscalWeek", expr: "valueof(RV_PREV_FISCAL_WEEK)", kind: "text" }, { name: "previousPreviousFiscalWeek", expr: "valueof(RV_PREV_PREV_FISCAL_WEEK)", kind: "text" }, { name: "previousPreviousPreviousFiscalWeek", expr: "valueof(RV_PREV_PREV_PREV_FISCAL_WEEK)", kind: "text" }, { name: "nextFiscalYear", expr: "valueof(RV_NEXT_FISCAL_YEAR)", kind: "text" }, ]; const EFFORT_TASK_TYPE_COLUMNS = [ { name: "taskType", expr: '"Effort Details"."Task Type"', kind: "text" }, { name: "hoursExcludingTimeOff", expr: '"Effort"."# Hours (Excl. Time Off)"', kind: "scalar" }, ]; const EFFORT_BY_TEAM_COLUMNS = [ { name: "seTeamLevel2EmailAddress", expr: '"SR Team"."SE Team Level 2 Email Address"', kind: "text" }, { name: "totalHours", expr: '"Effort"."# Hours (Excl. Time Off)"', kind: "scalar" }, ]; const OPPORTUNITIES_CLOSE_WINDOW_COLUMNS = [ { name: "opportunityId", expr: '"Opportunity"."Opportunity ID"', kind: "text" }, { name: "opportunityName", expr: '"Opportunity"."Opportunity Name"', kind: "text" }, { name: "customerName", expr: '"Customer"."Customer Name"', kind: "text" }, { name: "opportunityStatus", expr: '"Opportunity"."Status"', kind: "text" }, { name: "closeDate", expr: '"Opportunity"."Close Date"', kind: "scalar" }, { name: "salesStage", expr: '"Opportunity"."Sales Stage"', kind: "text" }, { name: "bookingValue", expr: '"Opportunity"."Opportunity Value"', kind: "scalar" }, { name: "workloadAmount", expr: '"Opportunity"."Workload Amount"', kind: "scalar" }, ]; const SRS_BY_RESOURCE_COLUMNS = [ { name: "srNumber", expr: '"Service Request"."SR Number"', kind: "text" }, { name: "srStatus", expr: '"Service Request"."Status"', kind: "text" }, { name: "title", expr: '"Service Request"."Title"', kind: "text" }, { name: "srSource", expr: '"Service Request"."SR Source"', kind: "text" }, { name: "serviceDescription", expr: '"Service Request"."Service Description"', kind: "text" }, { name: "customerName", expr: '"Customer"."Customer Name"', kind: "text" }, { name: "opportunityId", expr: '"Opportunity"."Opportunity ID"', kind: "text" }, { name: "opportunityName", expr: '"Opportunity"."Opportunity Name"', kind: "text" }, { name: "opportunityStatus", expr: '"Opportunity"."Status"', kind: "text" }, { name: "primaryPillar", expr: '"Service Request"."Primary Pillar"', kind: "text" }, { name: "leadEmail", expr: '"Service Request"."Lead Email"', kind: "text" }, { name: "queueName", expr: '"Service Request"."Queue Name"', kind: "text" }, { name: "internalDeadline", expr: '"Service Request"."Internal Deadline"', kind: "scalar" }, { name: "bookingValue", expr: '"Opportunity"."Opportunity Value"', kind: "scalar" }, { name: "workloadAmount", expr: '"Opportunity"."Workload Amount"', kind: "scalar" }, { name: "totalSrHours", expr: '"Service Request"."Total SR Hours"', kind: "scalar" }, { name: "lastEffort", expr: '"Service Request"."Last Effort"', kind: "scalar" }, ]; const CURRENT_TEAM_CLOSE_WINDOW_COLUMNS = [ "opportunityId", "opportunityName", "customerName", "opportunityStatus", "closeDate", "salesStage", "bookingValue", "workloadAmount", "teamMemberEmails", "currentTeamOpportunityHours", "coverageRows", ]; const WORKLOAD_MANAGER_RESOURCE_CLOSE_WINDOW_COLUMNS = [ "closeDate", "revenueLineId", "opportunityId", "opportunityName", "customerName", "workloadAmount", "managerEmails", "resourceEmails", "resourceDetails", ]; const SQL_NULL_TEXT = `CAST(NULL AS VARCHAR(${VARCHAR_SIZE}))`; const SQL_NULL_SCALAR = "CAST(NULL AS DOUBLE)"; const SA_ATTACH_PIPELINE_COLUMNS = [ { name: "revenueLineId", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line ID"), kind: "text" }, { name: "opportunityId", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), kind: "text" }, { name: "customerNameOriginal", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)"), kind: "text" }, { name: "solution", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Solution"), kind: "text" }, { name: "pipelineAmount", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline"), kind: "scalar" }, { name: "revenueLineStatus", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Status"), kind: "text" }, { name: "revenueTypeGroup", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Type Group"), kind: "text" }, { name: "salesCreditType", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Sales Credit Type"), kind: "text" }, { name: "revenueLineProbability", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Probability"), kind: "scalar" }, { name: "opportunityProbability", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Probability"), kind: "scalar" }, { name: "presalesInvolvementFlag", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Presales Involvement Flag"), kind: "text" }, { name: "actionToCloseFilledFlag", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Action to Close (Fusion)"), kind: "text" }, { name: "managerReview", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Manager Review"), kind: "text" }, { name: "executiveProductLob", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Lob"), kind: "text" }, { name: "executiveProductClass", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Class"), kind: "text" }, { name: "executiveProductPillar", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Pillar"), kind: "text" }, { name: "executiveProductLine", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Line"), kind: "text" }, { name: "productGroup", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Group"), kind: "text" }, { name: "productTier4", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Tier 4"), kind: "text" }, { name: "productTier5", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Tier 5"), kind: "text" }, { name: "productTier6", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Tier 6"), kind: "text" }, { name: "revenueLineForecastTypeGroup", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Forecast Type Group"), kind: "text" }, { name: "saasPurchaseCategory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "SaaS Purchase Category"), kind: "text" }, { name: "revenueLineCloseYear", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Year"), kind: "text" }, { name: "revenueLineCloseQuarter", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Quarter"), kind: "text" }, { name: "revenueLineCloseMonth", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Month"), kind: "text" }, { name: "revenueLineCloseDate", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Date"), kind: "scalar" }, { name: "territoryName", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Territory Name"), kind: "text" }, { name: "level2TerritoryOwnerEmail", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 2 Territory Owner E-mail"), kind: "text" }, { name: "level3TerritoryOwnerEmail", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 3 Territory Owner E-mail"), kind: "text" }, { name: "level4TerritoryOwnerEmail", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 4 Territory Owner E-mail"), kind: "text" }, { name: "level5TerritoryOwnerEmail", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 5 Territory Owner E-mail"), kind: "text" }, { name: "level6TerritoryOwnerEmail", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 6 Territory Owner E-mail"), kind: "text" }, { name: "level7TerritoryOwnerEmail", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 7 Territory Owner E-mail"), kind: "text" }, { name: "cluster", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Cluster"), kind: "text" }, { name: "segment", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Segment"), kind: "text" }, { name: "publicSectorFlag", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Public Sector Flag"), kind: "text" }, { name: "telcoFlag", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Telco Flag"), kind: "text" }, { name: "campaignSourceCode", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "All Campaign Source Code"), kind: "text" }, ]; const WORKLOAD_MANAGER_RESOURCE_PIPELINE_COLUMNS = [ { name: "closeDate", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Date"), kind: "scalar" }, { name: "revenueLineId", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line ID"), kind: "text" }, { name: "opportunityId", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), kind: "text" }, { name: "opportunityName", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Name"), kind: "text" }, { name: "customerName", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)"), kind: "text", }, { name: "workloadAmount", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline"), kind: "scalar" }, ]; const PRIMARY_OPPORTUNITY_WINDOW_COLUMNS = [ { name: "opportunityId", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), kind: "text" }, { name: "opportunityName", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Name"), kind: "text" }, { name: "customerName", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)"), kind: "text", }, { name: "opportunityStatus", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Status"), kind: "text" }, { name: "closeDate", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Date"), kind: "scalar" }, { name: "salesStage", expr: "''", kind: "text" }, { name: "bookingValue", expr: `MAX(${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline")})`, kind: "scalar", }, { name: "workloadAmount", expr: `MAX(${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline")})`, kind: "scalar", }, ]; const PRIMARY_OPPORTUNITY_DETAILS_COLUMNS = [ { name: "opportunityId", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), kind: "text" }, { name: "opportunityHours", expr: SQL_NULL_SCALAR, kind: "scalar" }, { name: "opportunityStatus", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Status"), kind: "text" }, { name: "workloadAmount", expr: `MAX(${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Workload Amount")})`, kind: "scalar", }, { name: "registryId", expr: SQL_NULL_TEXT, kind: "text" }, { name: "customerName", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)"), kind: "text", }, { name: "dealQualification", expr: SQL_NULL_TEXT, kind: "text" }, { name: "forecastTypeGroup", expr: SQL_NULL_TEXT, kind: "text" }, { name: "bookingValue", expr: `MAX(${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Value")})`, kind: "scalar", }, { name: "optyCloseFiscalQuarter", expr: SQL_NULL_TEXT, kind: "text" }, { name: "sesWithEffort", expr: SQL_NULL_SCALAR, kind: "scalar" }, { name: "serviceRequestsWithEffort", expr: SQL_NULL_SCALAR, kind: "scalar" }, { name: "country", expr: SQL_NULL_TEXT, kind: "text" }, { name: "salesStage", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Sales Stage"), kind: "text" }, ]; const SA_ATTACH_METRIC_COLUMNS = [ { name: "pipelineAmount", expr: `SUM(${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline")})`, kind: "scalar" }, ]; const SA_ATTACH_INVOLVEMENT_DISTRIBUTION_COLUMNS = [ { name: "involvementBucket", expr: buildSaAttachInvolvementBucketExpr(), kind: "text" }, { name: "revenueLineProbability", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Probability"), kind: "scalar" }, { name: "pipelineAmount", expr: `SUM(${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline")})`, kind: "scalar" }, ]; const SA_ATTACH_HOURS_COLUMNS = [ { name: "opportunityId", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Opportunity ID"), kind: "text" }, { name: "seTeamLevel1EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 1 Email Address"), kind: "text" }, { name: "seTeamLevel2EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 2 Email Address"), kind: "text" }, { name: "seTeamLevel3EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 3 Email Address"), kind: "text" }, { name: "seTeamLevel4EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 4 Email Address"), kind: "text" }, { name: "seTeamLevel5EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 5 Email Address"), kind: "text" }, { name: "seTeamLevel6EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 6 Email Address"), kind: "text" }, { name: "seTeamLevel7EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 7 Email Address"), kind: "text" }, { name: "seTeamLevel8EmailAddress", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "SE Team Level 8 Email Address"), kind: "text" }, { name: "opportunityHours", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "# Opportunity Hours"), kind: "scalar" }, { name: "wonFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Won Flag"), kind: "text" }, { name: "openFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Open Flag"), kind: "text" }, { name: "cloudApplicationsBookingsFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Cloud Applications - Bookings Flag"), kind: "text" }, { name: "cloudInfrastructureBookingsFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Cloud Infrastructure - Bookings Flag"), kind: "text" }, { name: "cloudInfrastructureWorkloadsFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Cloud Infrastructure - Workloads Flag"), kind: "text" }, { name: "onPremiseApplicationsBookingsFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "On-Premise Applications - Bookings Flag"), kind: "text" }, { name: "onPremiseTechnologyBookingsFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "On-Premise Technology - Bookings Flag"), kind: "text" }, { name: "hardwareBookingsFlag", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Hardware - Bookings Flag"), kind: "text" }, ]; const SA_ATTACH_PRESALES_AUX_COLUMNS = [ { name: "opportunityId", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "Opportunity ID"), kind: "text" }, { name: "seTeamLevel1EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 1 Email Address"), kind: "text" }, { name: "seTeamLevel2EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 2 Email Address"), kind: "text" }, { name: "seTeamLevel3EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 3 Email Address"), kind: "text" }, { name: "seTeamLevel4EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 4 Email Address"), kind: "text" }, { name: "seTeamLevel5EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 5 Email Address"), kind: "text" }, { name: "seTeamLevel6EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 6 Email Address"), kind: "text" }, { name: "seTeamLevel7EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 7 Email Address"), kind: "text" }, { name: "seTeamLevel8EmailAddress", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 8 Email Address"), kind: "text" }, { name: "opportunityHours", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "# Opportunity Hours"), kind: "scalar" }, { name: "opportunityHoursAttribute", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "Opportunity Hours Attribute"), kind: "scalar" }, ]; const FIELD_CATALOG = [ { alias: "opportunityId", entity: "Opportunity", expr: '"Opportunity"."Opportunity ID"', kind: "text", roles: ["select", "order"], description: "Stable Oracle opportunity identifier.", }, { alias: "opportunityName", entity: "Opportunity", expr: '"Opportunity"."Opportunity Name"', kind: "text", roles: ["select", "search"], description: "Opportunity name shown in the workbook.", }, { alias: "opportunityStatus", entity: "Opportunity", expr: '"Opportunity"."Status"', kind: "text", roles: ["select", "filter"], description: "Opportunity lifecycle status such as Open, Won, Closed, or Won Pending.", }, { alias: "closeDate", entity: "Opportunity", expr: '"Opportunity"."Close Date"', kind: "date", roles: ["select", "filter", "order"], description: "Close-date alias. In org-wide Knowledge DV - Opportunities - V2 queries this resolves to Revenue Line Close Date; filter with DATE literals such as DATE '2026-03-27'.", }, { alias: "salesStage", entity: "Opportunity", expr: '"Opportunity"."Sales Stage"', kind: "text", roles: ["select", "filter"], description: "Sales stage label such as 1. Engage or 6. Close.", }, { alias: "opportunityValue", entity: "Opportunity", expr: '"Opportunity"."Opportunity Value"', kind: "scalar", roles: ["select", "filter", "aggregate"], description: "Opportunity value measure. In pipeline-style outputs, treat this as bookingValue.", }, { alias: "bookingValue", entity: "Opportunity", expr: '"Opportunity"."Opportunity Value"', kind: "scalar", roles: ["select", "filter", "aggregate"], description: "Booking value alias backed by \"Opportunity\".\"Opportunity Value\".", }, { alias: "workloadAmount", entity: "Opportunity", expr: '"Opportunity"."Workload Amount"', kind: "scalar", roles: ["select", "filter", "aggregate"], description: "Workload amount measure commonly used in pipeline views.", }, { alias: "dealQualification", entity: "Opportunity", expr: '"Opportunity"."Deal Qualification"', kind: "text", roles: ["select", "filter"], description: "Deal qualification attribute from the opportunity entity.", }, { alias: "forecastTypeGroup", entity: "Opportunity", expr: '"Opportunity"."Forecast Type Group"', kind: "text", roles: ["select", "filter"], description: "Forecast grouping used in workbook slices.", }, { alias: "customerName", entity: "Customer", expr: '"Customer"."Customer Name"', kind: "text", roles: ["select", "filter", "search"], description: "Customer account display name.", }, { alias: "registryId", entity: "Customer", expr: '"Customer"."Registry ID"', kind: "text", roles: ["select", "filter"], description: "Customer registry identifier.", }, { alias: "country", entity: "Customer", expr: '"Customer"."Country"', kind: "text", roles: ["select", "filter"], description: "Customer country.", }, { alias: "securityEntryPoint", entity: "Security", expr: '"Security"."Entry Point"', kind: "text", roles: ["filter"], description: "Security entry point. Usually filter with VALUEOF(NQ_SESSION.\"SEC_ARIA_SI-SR-TEAM\").", }, { alias: "optyCloseFiscalYear", entity: "Time (Close Date Opportunity)", expr: '"Time (Close Date Opportunity)"."Opty Close Fiscal Year"', kind: "text", roles: ["filter", "date-part"], description: "Opportunity close fiscal year bucket used by the default workbook filters.", }, { alias: "optyCloseFiscalQuarter", entity: "Time (Close Date Opportunity)", expr: '"Time (Close Date Opportunity)"."Opty Close Fiscal Quarter"', kind: "text", roles: ["select", "filter", "date-part"], description: "Opportunity close fiscal quarter.", }, { alias: "optyCloseFiscalMonth", entity: "Time (Close Date Opportunity)", expr: '"Time (Close Date Opportunity)"."Opty Close Fiscal Month"', kind: "text", roles: ["select", "filter", "date-part"], description: "Opportunity close fiscal month.", }, { alias: "srNumber", entity: "Service Request", expr: '"Service Request"."SR Number"', kind: "text", roles: ["select", "filter", "order"], description: "Service request number.", }, { alias: "srStatus", entity: "Service Request", expr: '"Service Request"."Status"', kind: "text", roles: ["select", "filter"], description: "Service request status.", }, { alias: "srSource", entity: "Service Request", expr: '"Service Request"."SR Source"', kind: "text", roles: ["select", "filter"], description: "Service request source such as Opportunity.", }, { alias: "title", entity: "Service Request", expr: '"Service Request"."Title"', kind: "text", roles: ["select", "search"], description: "Service request title.", }, { alias: "queueName", entity: "Service Request", expr: '"Service Request"."Queue Name"', kind: "text", roles: ["select", "filter"], description: "Service request queue name.", }, { alias: "primaryPillar", entity: "Service Request", expr: '"Service Request"."Primary Pillar"', kind: "text", roles: ["select", "filter"], description: "Primary pillar classification for the SR.", }, { alias: "leadEmail", entity: "Service Request", expr: '"Service Request"."Lead Email"', kind: "text", roles: ["select", "filter"], description: "Lead email on the SR. Use only when the intent is specifically to find the SR leader or opportunity leader.", }, { alias: "srTeamLevel1EmailAddress", entity: "SR Team", expr: '"SR Team"."SE Team Level 1 Email Address"', kind: "text", roles: ["select", "filter"], description: "SR team level 1 member email. Use for participant/resource matching.", }, { alias: "srTeamLevel2EmailAddress", entity: "SR Team", expr: '"SR Team"."SE Team Level 2 Email Address"', kind: "text", roles: ["select", "filter"], description: "SR team level 2 member email. Use for participant/resource matching.", }, { alias: "srTeamLevel3EmailAddress", entity: "SR Team", expr: '"SR Team"."SE Team Level 3 Email Address"', kind: "text", roles: ["select", "filter"], description: "SR team level 3 member email. Use for participant/resource matching.", }, { alias: "srTeamLevel4EmailAddress", entity: "SR Team", expr: '"SR Team"."SE Team Level 4 Email Address"', kind: "text", roles: ["select", "filter"], description: "SR team level 4 member email. Use for participant/resource matching.", }, { alias: "customerDeadline", entity: "Service Request", expr: '"Service Request"."Customer Deadline"', kind: "date", roles: ["select", "filter"], description: "Customer deadline date from the SR entity.", }, { alias: "createSrDay", entity: "Time (Create Date Service Request)", expr: '"Time (Create Date Service Request)"."Create SR Day"', kind: "date", roles: ["select", "filter", "date-part"], description: "SR creation day.", }, { alias: "closeSrDay", entity: "Time (Close Date Service Request)", expr: '"Time (Close Date Service Request)"."Close SR Day"', kind: "date", roles: ["select", "filter", "date-part"], description: "SR close day.", }, { alias: "opportunityHours", entity: "Effort", expr: '"Effort"."# Opportunity Hours"', kind: "scalar", roles: ["select", "aggregate", "filter"], description: "Opportunity effort hours measure.", }, { alias: "hoursExcludingTimeOff", entity: "Effort", expr: '"Effort"."# Hours (Excl. Time Off)"', kind: "scalar", roles: ["select", "aggregate", "filter"], description: "Effort hours excluding time off.", }, { alias: "serviceRequestsWithEffort", entity: "Effort", expr: '"Effort"."# Service Requests with Effort"', kind: "scalar", roles: ["select", "aggregate"], description: "Count of service requests with recorded effort.", }, { alias: "sesWithEffort", entity: "Effort", expr: '"Effort"."# SEs With Effort"', kind: "scalar", roles: ["select", "aggregate"], description: "Count of SEs with effort.", }, { alias: "pipelineAmount", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline"), kind: "scalar", roles: ["select", "aggregate", "filter"], description: "Pipeline measure used by SA Attach and revenue-line style views.", }, { alias: "revenueLineId", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line ID"), kind: "text", roles: ["select", "order"], description: "Revenue line identifier from the SA Attach opportunity dataset.", }, { alias: "revenueLineStatus", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Status"), kind: "text", roles: ["select", "filter"], description: "Revenue line lifecycle status such as Open, Won, or Won Pending.", }, { alias: "revenueLineProbability", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Probability"), kind: "scalar", roles: ["select", "filter", "aggregate"], description: "Revenue line probability used in the SA Attach involvement distribution.", }, { alias: "revenueTypeGroup", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Type Group"), kind: "text", roles: ["select", "filter"], description: "Revenue type group such as NEW, EXPANSION, or WORKLOAD.", }, { alias: "salesCreditType", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Sales Credit Type"), kind: "text", roles: ["select", "filter"], description: "Sales credit type such as QUOTA.", }, { alias: "solution", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Solution"), kind: "text", roles: ["select", "filter"], description: "Normalized SA Attach solution family.", }, { alias: "executiveProductLob", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Lob"), kind: "text", roles: ["select", "filter"], description: "Executive product LOB used by SA Attach defaults.", }, { alias: "executiveProductClass", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Class"), kind: "text", roles: ["select", "filter"], description: "Executive product class from the SA Attach opportunity dataset.", }, { alias: "executiveProductPillar", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Pillar"), kind: "text", roles: ["select", "filter"], description: "Executive product pillar from the SA Attach opportunity dataset.", }, { alias: "executiveProductLine", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Executive Product Line"), kind: "text", roles: ["select", "filter"], description: "Executive product line from the SA Attach opportunity dataset.", }, { alias: "productGroup", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Group"), kind: "text", roles: ["select", "filter"], description: "Product group filter exposed on the SA Attach tab.", }, { alias: "productTier4", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Tier 4"), kind: "text", roles: ["select", "filter"], description: "Product tier 4 filter exposed on the SA Attach tab.", }, { alias: "productTier5", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Tier 5"), kind: "text", roles: ["select", "filter"], description: "Product tier 5 filter exposed on the SA Attach tab.", }, { alias: "productTier6", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Product Tier 6"), kind: "text", roles: ["select", "filter"], description: "Product tier 6 filter exposed on the SA Attach tab.", }, { alias: "revenueLineForecastTypeGroup", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Forecast Type Group"), kind: "text", roles: ["select", "filter"], description: "Revenue line forecast type group from the SA Attach opportunity dataset.", }, { alias: "saasPurchaseCategory", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "SaaS Purchase Category"), kind: "text", roles: ["select", "filter"], description: "SaaS purchase category exposed on the SA Attach tab.", }, { alias: "revenueLineCloseDate", entity: "Revenue Line", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Date"), kind: "date", roles: ["select", "filter", "order", "date-part"], description: "Daily revenue-line close date from the SA Attach opportunity dataset.", }, { alias: "opportunityProbability", entity: "Opportunity", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Probability"), kind: "scalar", roles: ["select", "filter", "aggregate"], description: "Opportunity probability used by the SA Attach tab defaults.", }, { alias: "presalesInvolvementFlag", entity: "Opportunity", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Presales Involvement Flag"), kind: "text", roles: ["select", "filter"], description: "Presales involvement flag from the SA Attach opportunity dataset.", }, { alias: "actionToCloseFilledFlag", entity: "Opportunity", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Action to Close (Fusion)"), kind: "text", roles: ["select", "filter"], description: "Action-to-close flag exposed on the SA Attach tab.", }, { alias: "managerReview", entity: "Opportunity", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Manager Review"), kind: "text", roles: ["select", "filter"], description: "Manager review state exposed on the SA Attach tab.", }, { alias: "territoryName", entity: "Territory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Territory Name"), kind: "text", roles: ["select", "filter"], description: "Territory name from the SA Attach opportunity dataset.", }, { alias: "territoryOwnerEmail", entity: "Territory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Level 7 Territory Owner E-mail"), kind: "text", roles: ["select", "filter"], description: "Direct territory-owner email on the SA Attach opportunity dataset.", }, { alias: "cluster", entity: "Territory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Cluster"), kind: "text", roles: ["select", "filter"], description: "Cluster filter exposed on SA Attach. The traced default is Brazil.", }, { alias: "segment", entity: "Territory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Segment"), kind: "text", roles: ["select", "filter"], description: "Segment filter exposed on the SA Attach tab.", }, { alias: "publicSectorFlag", entity: "Territory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Public Sector Flag"), kind: "text", roles: ["select", "filter"], description: "Public sector flag exposed on the SA Attach tab.", }, { alias: "telcoFlag", entity: "Territory", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Telco Flag"), kind: "text", roles: ["select", "filter"], description: "Telco flag exposed on the SA Attach tab.", }, { alias: "campaignSourceCode", entity: "Campaign", expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "All Campaign Source Code"), kind: "text", roles: ["select", "filter"], description: "Campaign source code filter exposed on the SA Attach tab.", }, { alias: "seTeamLevel1EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 1 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 1 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel2EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 2 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 2 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel3EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 3 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 3 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel4EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 4 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 4 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel5EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 5 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 5 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel6EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 6 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 6 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel7EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 7 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 7 email. Useful for explicit manager/resource matching.", }, { alias: "seTeamLevel8EmailAddress", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "SE Team Level 8 Email Address"), kind: "text", roles: ["select", "filter"], description: "SA Attach presales coverage level 8 email. Useful for explicit manager/resource matching.", }, { alias: "opportunityHoursAttribute", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "Opportunity Hours Attribute"), kind: "scalar", roles: ["select", "aggregate", "filter"], description: "Opportunity hours attribute used by the SA Attach my-team involvement formula.", }, { alias: "wonFlag", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Won Flag"), kind: "text", roles: ["select", "filter"], description: "Won flag from the SA Attach hours dataset.", }, { alias: "openFlag", entity: "Presales Involvement", expr: xsaColumn(SA_ATTACH_HOURS_DATASET, "Open Flag"), kind: "text", roles: ["select", "filter"], description: "Open flag from the SA Attach hours dataset.", }, ]; const QUERY_ORG_WIDE_FIELD_OVERRIDES = { opportunityId: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID") }, opportunityName: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Name") }, opportunityStatus: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Status") }, closeDate: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Date") }, salesStage: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Sales Stage") }, opportunityValue: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline") }, bookingValue: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline") }, workloadAmount: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Pipeline") }, customerName: { expr: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)") }, }; const QUERY_MY_TEAM_ONLY_ALIAS_MARKERS = new Set([ "srnumber", "srstatus", "srsource", "title", "queuename", "primarypillar", "leademail", "srteamlevel1emailaddress", "srteamlevel2emailaddress", "srteamlevel3emailaddress", "srteamlevel4emailaddress", "customerdeadline", "createsrday", "closesrday", "securityentrypoint", "hoursexcludingtimeoff", "servicerequests", ]); function buildSaAttachParameters(defaultStatuses = SA_ATTACH_DEFAULT_ALL_STATUSES) { return [ { name: "cluster", cli: "--cluster", required: false, default: SA_ATTACH_DEFAULT_CLUSTER, description: "Cluster filter. Defaults to Brazil to match the traced SA Attach tab.", }, { name: "solution", cli: "--solution", required: false, default: SA_ATTACH_DEFAULT_SOLUTIONS.join(","), description: "Optional comma-separated solution filter for SA Attach pipeline views.", }, { name: "revenueLineStatus", cli: "--revenue-line-status", required: false, default: defaultStatuses.join(","), description: "Optional comma-separated revenue-line statuses such as Open,Won,Won Pending.", }, { name: "executiveProductLob", cli: "--executive-product-lob", required: false, default: SA_ATTACH_DEFAULT_PRODUCT_LOBS.join(","), description: "Optional comma-separated executive product LOB filter.", }, { name: "revenueTypeGroup", cli: "--revenue-type-group", required: false, default: SA_ATTACH_DEFAULT_REVENUE_TYPE_GROUPS.join(","), description: "Optional comma-separated revenue type groups such as NEW,EXPANSION,WORKLOAD.", }, { name: "salesCreditType", cli: "--sales-credit-type", required: false, default: SA_ATTACH_DEFAULT_SALES_CREDIT_TYPE, description: "Sales credit type. Defaults to QUOTA to match the traced SA Attach tab.", }, { name: "minOpportunityProbability", cli: "--min-opportunity-probability", required: false, default: String(SA_ATTACH_DEFAULT_MIN_OPPORTUNITY_PROBABILITY), description: "Minimum opportunity probability. Defaults to 0.", }, { name: "ownerEmail", cli: "--owner-email", required: false, description: "Optional territory-owner email filter. Matches the direct territory owner on the opportunity row.", }, { name: "ownerManagerEmail", cli: "--owner-manager-email", required: false, description: "Optional manager-of-owner email filter. Matches upper territory-owner hierarchy levels on the opportunity row.", }, { name: "forecastType", cli: "--forecast-type", required: false, description: "Optional forecast-type filter such as Forecast, Upside, or Won.", }, { name: "date", cli: "--date", required: false, description: "Optional revenue-line close date shortcut for SA Attach reads.", }, { name: "month", cli: "--month", required: false, description: "Optional revenue-line close month shortcut for SA Attach reads. Also accepts current-month.", }, { name: "quarter", cli: "--quarter", required: false, description: "Optional revenue-line close quarter shortcut for SA Attach reads. Also accepts current-quarter.", }, { name: "week", cli: "--week", required: false, description: "Optional revenue-line close week shortcut for SA Attach reads. Also accepts current-week.", }, ]; } const VIEW_DEFS = { "current-fiscal-year": { description: "Returns the Oracle DV session fiscal year.", entities: ["Session Variables"], fields: ["currentFiscalYear"], primarySource: SOURCE_DV_SE_TEAM, buildSql: () => 'SELECT valueof(RV_CURR_FISCAL_YEAR) FROM "DV - SE Team"', }, "opportunity-details": { description: "Opportunity extract that uses Knowledge DV - Opportunities - V2 as the primary commercial source for the org-wide hierarchy. DV - SE Team is only eligible as fallback for explicit current-team reads.", entities: ["Opportunity", "Effort", "Customer", "Service Request", "SR Team", "Security"], defaultStatuses: ["Open", "Won", "Won Pending"], defaultLimit: 5000, primarySource: SOURCE_OPPORTUNITIES, fallbackSource: SOURCE_DV_SE_TEAM, fallbackScope: "my-team-only", fields: OPPORTUNITY_DETAILS_COLUMNS.map((column) => column.name), buildSql: ({ fiscalYear, statuses }) => buildDenseQuery({ columns: PRIMARY_OPPORTUNITY_DETAILS_COLUMNS, fromClause: `FROM ${SA_ATTACH_OPPORTUNITIES_DATASET}`, whereClauses: buildPrimaryOpportunityWhereClauses({ fiscalYear, statuses }), groupBy: [ xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Status"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Sales Stage"), ].join(", "), orderBy: xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), }), buildFallbackSql: ({ fiscalYear, statuses }) => buildDenseQuery({ columns: OPPORTUNITY_DETAILS_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', `"Time (Close Date Opportunity)"."Opty Close Fiscal Year" = ${quoteLiteral(fiscalYear)}`, `"Opportunity"."Status" IN (${toSqlList(statuses)})`, `"SR Team"."SE Team Active Flag" = 'Y'`, `"SR Team"."SE Team Manager Flag" = 'N'`, `"Service Request"."SR Source" = 'Opportunity'`, ], orderBy: '"Opportunity"."Opportunity ID"', }), }, "sr-details": { description: "Row-level service request extract with the workbook defaults.", entities: ["Service Request", "Opportunity", "Customer", "Effort", "SR Team", "SR Requester", "Security"], defaultStatuses: ["Open"], defaultLimit: 5000, primarySource: SOURCE_DV_SE_TEAM, fields: SR_DETAILS_COLUMNS.map((column) => column.name), buildSql: ({ fiscalYear, statuses }) => buildDenseQuery({ columns: SR_DETAILS_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', `"Time (Close Date Opportunity)"."Opty Close Fiscal Year" = ${quoteLiteral(fiscalYear)}`, `"Opportunity"."Status" IN (${toSqlList(statuses)})`, `"SR Team"."SE Team Active Flag" = 'Y'`, `"SR Team"."SE Team Manager Flag" = 'N'`, ], orderBy: '"Service Request"."SR Number"', }), }, "revenue-line-details": { description: "Row-level revenue-line extract from the XSA revenue dataset.", entities: ["Revenue Line", "Opportunity", "Customer", "SR Team"], defaultStatuses: ["Open", "Won", "Won Pending"], defaultLimit: 5000, primarySource: SOURCE_REVENUE_LINES, fields: REVENUE_LINE_COLUMNS.map((column) => column.name), buildSql: ({ fiscalYear, previousFiscalYear, statuses, scope = SCOPE_ORG_WIDE }) => buildDenseQuery({ columns: REVENUE_LINE_COLUMNS, fromClause: `FROM ${SA_ATTACH_REVENUE_LINES_DATASET}`, whereClauses: [ ...buildXsaScopePredicates(SA_ATTACH_REVENUE_LINES_DATASET, scope), `${xsaColumn(SA_ATTACH_REVENUE_LINES_DATASET, "Cluster")} = 'Brazil'`, `${xsaColumn(SA_ATTACH_REVENUE_LINES_DATASET, "Sales Credit Type")} = 'QUOTA'`, `${xsaColumn(SA_ATTACH_REVENUE_LINES_DATASET, "Revenue Line Status")} IN (${toSqlList(statuses)})`, `( ${xsaColumn(SA_ATTACH_REVENUE_LINES_DATASET, "Revenue Line Status")} = 'Open' OR ${xsaColumn(SA_ATTACH_REVENUE_LINES_DATASET, "Revenue Line Close Year")} IN (${toSqlList( [previousFiscalYear, fiscalYear].filter(Boolean) )}) )`, ], orderBy: xsaColumn(SA_ATTACH_REVENUE_LINES_DATASET, "Revenue Line ID"), }), }, "sa-attach-pipeline-details": { description: "Row-level SA Attach pipeline extract from Knowledge DV - Opportunities - V2 with the traced tab defaults.", entities: ["Revenue Line", "Opportunity", "Customer", "Territory", "Campaign"], defaultStatuses: SA_ATTACH_DEFAULT_ALL_STATUSES, defaultLimit: 5000, primarySource: SOURCE_OPPORTUNITIES, fields: SA_ATTACH_PIPELINE_COLUMNS.map((column) => column.name), parameters: buildSaAttachParameters(SA_ATTACH_DEFAULT_ALL_STATUSES), buildSql: ({ fiscalYear, previousFiscalYear, fromDateSql, toDateSql, saAttachFilters }) => buildDenseQuery({ columns: SA_ATTACH_PIPELINE_COLUMNS, fromClause: `FROM ${SA_ATTACH_OPPORTUNITIES_DATASET}`, whereClauses: buildSaAttachOpportunityWhereClauses({ dataset: SA_ATTACH_OPPORTUNITIES_DATASET, fiscalYear, previousFiscalYear, fromDateSql, toDateSql, ...saAttachFilters, }), orderBy: `${xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line ID")}`, }), }, "sa-attach-open-pipeline": { description: "Single-row open pipeline metric from the SA Attach opportunity dataset with the traced tab defaults.", entities: ["Revenue Line", "Opportunity", "Customer", "Territory"], defaultStatuses: SA_ATTACH_DEFAULT_OPEN_STATUSES, defaultLimit: 1, primarySource: SOURCE_OPPORTUNITIES, fields: SA_ATTACH_METRIC_COLUMNS.map((column) => column.name), parameters: buildSaAttachParameters(SA_ATTACH_DEFAULT_OPEN_STATUSES), buildSql: ({ fiscalYear, previousFiscalYear, fromDateSql, toDateSql, saAttachFilters }) => buildDenseQuery({ columns: SA_ATTACH_METRIC_COLUMNS, fromClause: `FROM ${SA_ATTACH_OPPORTUNITIES_DATASET}`, whereClauses: buildSaAttachOpportunityWhereClauses({ dataset: SA_ATTACH_OPPORTUNITIES_DATASET, fiscalYear, previousFiscalYear, fromDateSql, toDateSql, ...saAttachFilters, }), }), }, "sa-attach-won-pipeline": { description: "Single-row won pipeline metric from the SA Attach opportunity dataset with the traced tab defaults.", entities: ["Revenue Line", "Opportunity", "Customer", "Territory"], defaultStatuses: SA_ATTACH_DEFAULT_WON_STATUSES, defaultLimit: 1, primarySource: SOURCE_OPPORTUNITIES, fields: SA_ATTACH_METRIC_COLUMNS.map((column) => column.name), parameters: buildSaAttachParameters(SA_ATTACH_DEFAULT_WON_STATUSES), buildSql: ({ fiscalYear, previousFiscalYear, fromDateSql, toDateSql, saAttachFilters }) => buildDenseQuery({ columns: SA_ATTACH_METRIC_COLUMNS, fromClause: `FROM ${SA_ATTACH_OPPORTUNITIES_DATASET}`, whereClauses: buildSaAttachOpportunityWhereClauses({ dataset: SA_ATTACH_OPPORTUNITIES_DATASET, fiscalYear, previousFiscalYear, fromDateSql, toDateSql, ...saAttachFilters, }), }), }, "sa-attach-involvement-distribution": { description: "Aggregated SA Attach distribution of pipeline by involvement bucket and revenue-line probability.", entities: ["Revenue Line", "Opportunity", "Presales Involvement"], defaultStatuses: SA_ATTACH_DEFAULT_OPEN_STATUSES, defaultLimit: 100, primarySource: SOURCE_OPPORTUNITIES, fields: SA_ATTACH_INVOLVEMENT_DISTRIBUTION_COLUMNS.map((column) => column.name), parameters: buildSaAttachParameters(SA_ATTACH_DEFAULT_OPEN_STATUSES), buildSql: ({ fiscalYear, previousFiscalYear, fromDateSql, toDateSql, saAttachFilters }) => buildDenseQuery({ columns: SA_ATTACH_INVOLVEMENT_DISTRIBUTION_COLUMNS, fromClause: `FROM ${SA_ATTACH_OPPORTUNITIES_DATASET}`, whereClauses: buildSaAttachOpportunityWhereClauses({ dataset: SA_ATTACH_OPPORTUNITIES_DATASET, fiscalYear, previousFiscalYear, fromDateSql, toDateSql, ...saAttachFilters, }), groupBy: `${buildSaAttachInvolvementBucketExpr()}, ${xsaColumn( SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Probability" )}`, orderBy: "c0, c1", }), }, "sa-attach-hours-by-opportunity": { description: "Row-level SA Attach hours extract from Knowledge DV - Hours - V2. Defaults to org-wide and supports --scope my-team for current-session team filtering.", entities: ["Presales Involvement", "Opportunity", "SR Team"], defaultLimit: 5000, needsFiscalYear: false, primarySource: SOURCE_HOURS, fields: SA_ATTACH_HOURS_COLUMNS.map((column) => column.name), buildSql: ({ scope = SCOPE_ORG_WIDE } = {}) => buildDenseQuery({ columns: SA_ATTACH_HOURS_COLUMNS, fromClause: `FROM ${SA_ATTACH_HOURS_DATASET}`, whereClauses: buildXsaScopePredicates(SA_ATTACH_HOURS_DATASET, scope), orderBy: `${xsaColumn(SA_ATTACH_HOURS_DATASET, "Opportunity ID")}`, }), }, "sa-attach-presales-coverage": { description: "Row-level SA Attach presales coverage extract from Knowledge DV - Presales Involvement Aux - V1. Defaults to org-wide and supports --scope my-team for current-session team filtering.", entities: ["Presales Involvement", "Opportunity", "SR Team"], defaultLimit: 5000, needsFiscalYear: false, primarySource: SOURCE_PRESALES_AUX, fields: SA_ATTACH_PRESALES_AUX_COLUMNS.map((column) => column.name), buildSql: ({ scope = SCOPE_ORG_WIDE } = {}) => buildDenseQuery({ columns: SA_ATTACH_PRESALES_AUX_COLUMNS, fromClause: `FROM ${SA_ATTACH_PRESALES_AUX_DATASET}`, whereClauses: buildXsaScopePredicates(SA_ATTACH_PRESALES_AUX_DATASET, scope), orderBy: `${xsaColumn(SA_ATTACH_PRESALES_AUX_DATASET, "Opportunity ID")}`, }), }, "won-and-open-by-se-opty": { description: "One row per opportunity and SE Team Level 2 member contribution.", entities: ["Opportunity", "Customer", "Effort", "SR Team", "Service Request", "Security"], defaultStatuses: ["Open", "Won", "Won Pending"], defaultLimit: 5000, primarySource: SOURCE_DV_SE_TEAM, fields: WON_AND_OPEN_COLUMNS.map((column) => column.name), buildSql: ({ fiscalYear, statuses }) => buildDenseQuery({ columns: WON_AND_OPEN_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', `"Time (Close Date Opportunity)"."Opty Close Fiscal Year" = ${quoteLiteral(fiscalYear)}`, `"Opportunity"."Status" IN (${toSqlList(statuses)})`, `"SR Team"."SE Team Active Flag" = 'Y'`, `"SR Team"."SE Team Manager Flag" = 'N'`, `"Service Request"."SR Source" = 'Opportunity'`, `("Effort"."# Opportunity Hours" / (SUM("Effort"."# Opportunity Hours" BY "Opportunity"."Opportunity ID"))) > 0`, ], orderBy: '"Opportunity"."Opportunity ID", "SR Team"."SE Team Level 2 Email Address"', }), }, "opportunities-close-window": { description: "One row per opportunity with close date constrained to a direct calendar-date window. It uses Knowledge DV - Opportunities - V2 as the primary org-wide commercial source. DV - SE Team is only eligible as fallback for explicit current-team reads.", entities: ["Opportunity", "Customer", "Security"], defaultLimit: 5000, defaultStatuses: SA_ATTACH_DEFAULT_ALL_STATUSES, needsFiscalYear: false, primarySource: SOURCE_OPPORTUNITIES, fallbackSource: SOURCE_DV_SE_TEAM, fallbackScope: "my-team-only", parameters: [ { name: "fromDate", cli: "--from-date", required: false, default: "today", description: "Start of the close-date window. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "toDate", cli: "--to-date", required: false, default: "+7d", description: "End of the close-date window. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won,Closed.", }, ], fields: OPPORTUNITIES_CLOSE_WINDOW_COLUMNS.map((column) => column.name), buildSql: ({ fromDateSql, toDateSql, statuses, cluster = null, ownerEmail = null, ownerManagerEmail = null }) => buildSelectQuery({ columns: PRIMARY_OPPORTUNITY_WINDOW_COLUMNS, fromClause: `FROM ${SA_ATTACH_OPPORTUNITIES_DATASET}`, whereClauses: buildPrimaryOpportunityWhereClauses({ fromDateSql, toDateSql, statuses, cluster, ownerEmail, ownerManagerEmail, }), groupBy: [ xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity ID"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Name"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Customer Name (Original)"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Opportunity Status"), xsaColumn(SA_ATTACH_OPPORTUNITIES_DATASET, "Revenue Line Close Date"), ].join(", "), orderBy: "closeDate, opportunityId", }), buildFallbackSql: ({ fromDateSql, toDateSql, statuses }) => buildDenseQuery({ distinct: true, columns: OPPORTUNITIES_CLOSE_WINDOW_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', `"Opportunity"."Close Date" >= ${fromDateSql}`, `"Opportunity"."Close Date" <= ${toDateSql}`, ...(statuses.length > 0 ? [`"Opportunity"."Status" IN (${toSqlList(statuses)})`] : []), ], orderBy: "c4, c0", }), }, "srs-by-resource-email": { description: "One row per SR for a resource email. By default it matches SR Team Level 1..4 member emails, and only uses Lead Email when explicitly requested.", entities: ["Service Request", "Opportunity", "Customer", "SR Team", "Security"], defaultLimit: 5000, defaultStatuses: [], needsFiscalYear: false, primarySource: SOURCE_DV_SE_TEAM, parameters: [ { name: "resourceEmail", cli: "--resource-email", required: true, description: "Oracle email of the resource to match against SR Team Level 1..4 by default.", }, { name: "matchRole", cli: "--match-role", required: false, default: "team", description: "Use team for SR Team Level 1..4 membership, or lead to match Service Request Lead Email explicitly.", }, { name: "srStatus", cli: "--sr-status", required: false, default: "all statuses", description: "Optional comma-separated SR statuses such as Delivery,Closed.", }, ], fields: SRS_BY_RESOURCE_COLUMNS.map((column) => column.name), buildSql: ({ resourceEmailSql, matchRole, srStatuses }) => buildDenseQuery({ distinct: true, columns: SRS_BY_RESOURCE_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', buildSrResourcePredicate(resourceEmailSql, matchRole), ...(srStatuses.length > 0 ? [`"Service Request"."Status" IN (${toSqlList(srStatuses)})`] : []), ], orderBy: "c0", }), }, "data-quality-session-context": { description: "Returns the DV session entry point plus fiscal period variables.", entities: ["Security", "Session Variables"], defaultLimit: 1, needsFiscalYear: false, primarySource: SOURCE_DV_SE_TEAM, fields: DATA_QUALITY_CONTEXT_COLUMNS.map((column) => column.name), buildSql: () => buildDenseQuery({ columns: DATA_QUALITY_CONTEXT_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: ['"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")'], orderBy: '"Security"."Entry Point"', }), }, "effort-task-type-summary": { description: "Aggregated effort hours by task type for a fiscal year.", entities: ["Effort", "Effort Details", "SR Team", "Security"], defaultLimit: 100, primarySource: SOURCE_DV_SE_TEAM, fields: EFFORT_TASK_TYPE_COLUMNS.map((column) => column.name), buildSql: ({ fiscalYear }) => buildDenseQuery({ columns: EFFORT_TASK_TYPE_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', `"Time (Effort)"."Effort Fiscal Year" = ${quoteLiteral(fiscalYear)}`, `"SR Team"."SE Team Active Flag" = 'Y'`, `"SR Team"."SE Team Manager Flag" = 'N'`, ], orderBy: '"Effort"."# Hours (Excl. Time Off)" DESC, "Effort Details"."Task Type"', }), }, "effort-by-se-team": { description: "Aggregated effort hours by SE Team Level 2 member for a fiscal year.", entities: ["Effort", "SR Team", "Security"], defaultLimit: 100, primarySource: SOURCE_DV_SE_TEAM, fields: EFFORT_BY_TEAM_COLUMNS.map((column) => column.name), buildSql: ({ fiscalYear }) => buildDenseQuery({ columns: EFFORT_BY_TEAM_COLUMNS, fromClause: 'FROM "DV - SE Team"', whereClauses: [ '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', `"Time (Effort)"."Effort Fiscal Year" = ${quoteLiteral(fiscalYear)}`, `"SR Team"."SE Team Active Flag" = 'Y'`, `"SR Team"."SE Team Manager Flag" = 'N'`, ], orderBy: '"Effort"."# Hours (Excl. Time Off)" DESC, "SR Team"."SE Team Level 2 Email Address"', }), }, }; function closeWindowClusterParameter() { return { name: "cluster", cli: "--cluster", required: false, description: "Optional explicit commercial opportunity Cluster filter. When omitted, the existing unfiltered geography behavior is preserved.", }; } function saAttachClusterParameter() { return { name: "cluster", cli: "--cluster", required: false, default: SA_ATTACH_DEFAULT_CLUSTER, description: "Optional SA Attach Cluster filter. Defaults to Brazil when omitted.", }; } function workloadClusterParameter() { return { name: "cluster", cli: "--cluster", required: false, default: SA_ATTACH_DEFAULT_CLUSTER, description: "Optional workload commercial Cluster filter. Defaults to Brazil when omitted.", }; } function closeWindowDateParameters() { return [ { name: "fromDate", cli: "--from-date", required: false, default: "today", description: "Start of the close-date window. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "toDate", cli: "--to-date", required: false, default: "+7d", description: "End of the close-date window. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "date", cli: "--date", required: false, description: "Exact close date. Shortcut for a one-day window.", }, { name: "month", cli: "--month", required: false, description: "Calendar month in YYYY-MM format. Shortcut for a full-month window.", }, { name: "quarter", cli: "--quarter", required: false, description: "Fiscal quarter in FY26-Q4 or Q4 FY26 format. Shortcut for a full fiscal-quarter window.", }, { name: "week", cli: "--week", required: false, description: "Annual week shortcut anchored on June 1. Accepts 1..53, w1..w53, or week 1..week 53.", }, { name: "weekYear", cli: "--week-year", required: false, default: "current June-cycle start year", description: "Cycle start year used with --week. For example, 2025 means the 2025-06-01 through 2026-05-31 cycle.", }, ]; } function limitParameter(description = "Optional row limit for the extract.") { return { name: "limit", cli: "--limit", required: false, default: "5000", description, }; } const INTENT_CATALOG = { "opportunities-default": { description: "Default opportunity path using the traced commercial pipeline defaults on Knowledge DV - Opportunities - V2.", view: "sa-attach-pipeline-details", parameters: [ saAttachClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the default commercial pipeline extract.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-default --limit 200`, ], }, "workloads-by-owner-current": { description: "Current-state workload view for one explicit territory owner, defaulting to the current fiscal quarter and workload solution family.", view: "sa-attach-pipeline-details", parameters: [ { name: "ownerEmail", cli: "--owner-email", required: true, description: "Territory-owner email to match on the direct owner of the workload row.", }, { name: "quarter", cli: "--quarter", required: false, default: "current-quarter", description: "Fiscal quarter in FY26-Q4 or Q4 FY26 format. Defaults to current-quarter.", }, { name: "forecastType", cli: "--forecast-type", required: false, default: "all forecast types", description: "Optional forecast-type filter such as Forecast or Upside.", }, saAttachClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the workload extract.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-owner-current --owner-email territory.owner@oracle.com`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-owner-current --owner-email territory.owner@oracle.com --forecast-type Forecast`, ], }, "workloads-by-owner-manager-current": { description: "Current-state workload view for owners under one explicit manager-of-owner, defaulting to the current fiscal quarter and workload solution family.", view: "sa-attach-pipeline-details", parameters: [ { name: "ownerManagerEmail", cli: "--owner-manager-email", required: true, description: "Upper territory-owner manager email to match in the hierarchy.", }, { name: "quarter", cli: "--quarter", required: false, default: "current-quarter", description: "Fiscal quarter in FY26-Q4 or Q4 FY26 format. Defaults to current-quarter.", }, { name: "forecastType", cli: "--forecast-type", required: false, default: "all forecast types", description: "Optional forecast-type filter such as Forecast or Upside.", }, saAttachClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the workload extract.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-owner-manager-current --owner-manager-email territory.manager@oracle.com`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-owner-manager-current --owner-manager-email territory.manager@oracle.com --forecast-type Forecast`, ], }, "workloads-by-owner-close-window": { description: "List org-wide workload revenue lines in a close-date window for one explicit territory owner.", view: "sa-attach-pipeline-details", parameters: [ { name: "ownerEmail", cli: "--owner-email", required: true, description: "Territory-owner email to match on the direct owner of the workload row.", }, ...closeWindowDateParameters(), { name: "forecastType", cli: "--forecast-type", required: false, default: "all forecast types", description: "Optional forecast-type filter such as Forecast, Upside, or Won.", }, workloadClusterParameter(), limitParameter("Optional row limit for the workload extract."), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-owner-close-window --owner-email territory.owner@oracle.com --month 2026-05`, ], }, "workloads-by-owner-manager-close-window": { description: "List org-wide workload revenue lines in a close-date window for territory owners under one explicit owner manager.", view: "sa-attach-pipeline-details", parameters: [ { name: "ownerManagerEmail", cli: "--owner-manager-email", required: true, description: "Upper territory-owner manager email to match in the workload owner hierarchy.", }, ...closeWindowDateParameters(), { name: "forecastType", cli: "--forecast-type", required: false, default: "all forecast types", description: "Optional forecast-type filter such as Forecast, Upside, or Won.", }, workloadClusterParameter(), limitParameter("Optional row limit for the workload extract."), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-owner-manager-close-window --owner-manager-email territory.manager@oracle.com --week w43`, ], }, "workloads-by-resource-close-window": { description: "List org-wide workload revenue lines in a close-date window for opportunities where one explicit resource appears in Presales Involvement Aux coverage.", view: "sa-attach-pipeline-details", parameters: [ { name: "resource", cli: "--resource", required: true, description: "Oracle user identifier. Accepts resource.member or resource.member@oracle.com.", }, ...closeWindowDateParameters(), { name: "forecastType", cli: "--forecast-type", required: false, default: "all forecast types", description: "Optional forecast-type filter such as Forecast, Upside, or Won.", }, workloadClusterParameter(), limitParameter("Optional row limit for the org-wide workload revenue-line extract before coverage intersection."), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-resource-close-window --resource resource.member --week w43`, ], }, "workloads-by-manager-resource-close-window": { description: "List org-wide workload revenue lines closing inside a date window, keeping only opportunities that have allocated presales resources under one or more explicit managers from Knowledge DV - Presales Involvement Aux - V1. This default intent is involvement/allocation only and does not fetch SR details from DV - SE Team.", view: "sa-attach-pipeline-details", parameters: [ { name: "managerEmailList", cli: "--manager-email-list", required: true, description: "Comma-separated manager emails used to anchor Presales Involvement Aux coverage. Accepts short ids or full @oracle.com emails.", }, { name: "managerEmail", cli: "--manager-email", required: false, description: "Optional single manager email. It is merged with --manager-email-list when both are present.", }, { name: "fromDate", cli: "--from-date", required: false, default: "today", description: "Start of the revenue-line close-date window. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "toDate", cli: "--to-date", required: false, default: "+7d", description: "End of the revenue-line close-date window. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "date", cli: "--date", required: false, description: "Exact revenue-line close date. Shortcut for a one-day window.", }, { name: "month", cli: "--month", required: false, description: "Calendar month in YYYY-MM format. Shortcut for a full-month revenue-line window.", }, { name: "quarter", cli: "--quarter", required: false, description: "Fiscal quarter in FY26-Q4 or Q4 FY26 format. Shortcut for a full fiscal-quarter revenue-line window.", }, { name: "week", cli: "--week", required: false, description: "Annual week shortcut anchored on June 1. Accepts 1..53, w1..w53, or week 1..week 53.", }, { name: "weekYear", cli: "--week-year", required: false, default: "current June-cycle start year", description: "Cycle start year used with --week. For example, 2025 means the 2025-06-01 through 2026-05-31 cycle.", }, workloadClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the org-wide workload revenue-line extract before coverage intersection.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-manager-resource-close-window --manager-email-list resource.manager.a@oracle.com,resource.manager.b@oracle.com --from-date today --to-date +7d`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent workloads-by-manager-resource-close-window --manager-email resource.manager@oracle.com --week w2 --week-year 2026`, ], }, "opportunities-close-date": { description: "List opportunities closing on one exact date.", view: "opportunities-close-window", parameters: [ { name: "date", cli: "--date", required: true, description: "Exact close date. Accepts YYYY-MM-DD, today, +7d, -3d, or today+7d.", }, { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won.", }, closeWindowClusterParameter(), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-close-date --date 2026-05-02`, ], }, "opportunities-close-month": { description: "List opportunities closing inside one calendar month.", view: "opportunities-close-window", parameters: [ { name: "month", cli: "--month", required: true, description: "Calendar month in YYYY-MM format, for example 2026-04.", }, { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won.", }, closeWindowClusterParameter(), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-close-month --month 2026-04`, ], }, "opportunities-close-quarter": { description: "List opportunities closing inside one fiscal quarter.", view: "opportunities-close-window", parameters: [ { name: "quarter", cli: "--quarter", required: true, description: "Fiscal quarter in FY26-Q4 or Q4 FY26 format. Also accepts current-quarter.", }, { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won.", }, closeWindowClusterParameter(), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-close-quarter --quarter FY26-Q4`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-close-quarter --quarter current-quarter`, ], }, "opportunities-by-owner-close-window": { description: "List org-wide commercial opportunities/workloads in a close-date window for one explicit territory owner.", view: "opportunities-close-window", parameters: [ { name: "ownerEmail", cli: "--owner-email", required: true, description: "Territory-owner email to match on the direct owner of the opportunity row.", }, ...closeWindowDateParameters(), { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won,Closed.", }, closeWindowClusterParameter(), limitParameter("Optional row limit for the opportunity window."), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-owner-close-window --owner-email territory.owner@oracle.com --week w43`, ], }, "opportunities-by-owner-manager-close-window": { description: "List org-wide commercial opportunities/workloads in a close-date window for territory owners under one explicit owner manager.", view: "opportunities-close-window", parameters: [ { name: "ownerManagerEmail", cli: "--owner-manager-email", required: true, description: "Upper territory-owner manager email to match in the opportunity owner hierarchy.", }, ...closeWindowDateParameters(), { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won,Closed.", }, closeWindowClusterParameter(), limitParameter("Optional row limit for the opportunity window."), ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-owner-manager-close-window --owner-manager-email territory.manager@oracle.com --month 2026-05`, ], }, "opportunities-current-team-close-window": { description: "List commercial opportunities/workloads in a close-date window and enrich them with current-team presales/SR coverage for the executing user when present. Org-wide opportunity rows are preserved even when no current-team resource matches.", view: "opportunities-close-window", parameters: [ ...closeWindowDateParameters(), { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won,Closed.", }, closeWindowClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the initial opportunity window before current-team coverage enrichment.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-current-team-close-window --from-date today --to-date +4d`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-current-team-close-window --date 2026-05-02`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-current-team-close-window --quarter current-quarter`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-current-team-close-window --week w2 --week-year 2026`, ], }, "opportunities-by-resource-close-window": { description: "List commercial opportunities/workloads in a close-date window and enrich them with presales coverage for one explicit Oracle resource email when present. Org-wide opportunity rows are preserved even when no resource match exists.", view: "opportunities-close-window", parameters: [ { name: "resource", cli: "--resource", required: true, description: "Oracle user identifier. Accepts resource.member or resource.member@oracle.com.", }, ...closeWindowDateParameters(), { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won,Closed.", }, closeWindowClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the initial opportunity window before coverage enrichment.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-resource-close-window --resource resource.member --month 2026-04`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-resource-close-window --resource resource.member --quarter current-quarter`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-resource-close-window --resource resource.member --week w2 --week-year 2026`, ], }, "opportunities-by-manager-close-window": { description: "List commercial opportunities/workloads in a close-date window and enrich them with coverage rows anchored to one explicit manager email when present. Org-wide opportunity rows are preserved even when no manager-team match exists.", view: "opportunities-close-window", parameters: [ { name: "managerEmail", cli: "--manager-email", required: true, description: "Manager email to match in the coverage hierarchy. Accepts resource.manager or resource.manager@oracle.com.", }, ...closeWindowDateParameters(), { name: "optyStatus", cli: "--opty-status", required: false, default: "all statuses", description: "Optional comma-separated opportunity statuses such as Open,Won,Closed.", }, closeWindowClusterParameter(), { name: "limit", cli: "--limit", required: false, default: "5000", description: "Optional row limit for the initial opportunity window before coverage enrichment.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-manager-close-window --manager-email resource.manager@oracle.com --month 2026-04`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-manager-close-window --manager-email resource.manager@oracle.com --quarter current-quarter`, `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent opportunities-by-manager-close-window --manager-email resource.manager@oracle.com --week w2 --week-year 2026`, ], }, "srs-by-resource": { description: "List SRs for one Oracle resource, matching SR Team Level 1..4 by default.", view: "srs-by-resource-email", parameters: [ { name: "resource", cli: "--resource", required: true, description: "Oracle user identifier. Accepts resource.member or resource.member@oracle.com.", }, { name: "matchRole", cli: "--match-role", required: false, default: "team", description: "Use team by default. Use lead only when explicitly looking for the SR leader.", }, { name: "srStatus", cli: "--sr-status", required: false, default: "all statuses", description: "Optional comma-separated SR statuses such as Delivery,Closed.", }, ], examples: [ `node "${path.resolve(process.argv[1] || "fetch-sales-intelligence.mjs")}" --intent srs-by-resource --resource resource.member`, ], }, }; const MACRO_CATALOG = { subjectArea: { description: 'Primary Oracle DV subject area for this skill.', resolve: () => '"DV - SE Team"', }, securityEntryPointFilter: { description: 'Team security predicate used by most direct queries.', resolve: () => '"Security"."Entry Point" = VALUEOF(NQ_SESSION."SEC_ARIA_SI-SR-TEAM")', }, sessionCurrentFiscalYear: { description: 'Oracle DV session expression for the current fiscal year.', resolve: () => "valueof(RV_CURR_FISCAL_YEAR)", }, sessionCurrentFiscalWeek: { description: 'Oracle DV session expression for the current fiscal week.', resolve: () => "valueof(RV_CURR_FISCAL_WEEK)", }, sessionPreviousFiscalWeek: { description: 'Oracle DV session expression for the previous fiscal week.', resolve: () => "valueof(RV_PREV_FISCAL_WEEK)", }, saAttachOpportunitiesSubjectArea: { description: "SA Attach opportunity XSA dataset used for pipeline and involvement views.", resolve: () => SA_ATTACH_OPPORTUNITIES_DATASET, }, saAttachHoursSubjectArea: { description: "SA Attach hours XSA dataset. It is org-wide-capable; add --scope my-team or a session filter for current-team reads.", resolve: () => SA_ATTACH_HOURS_DATASET, }, saAttachPresalesAuxSubjectArea: { description: "SA Attach presales-coverage XSA dataset. It is org-wide-capable; add --scope my-team or a session filter for current-team reads.", resolve: () => SA_ATTACH_PRESALES_AUX_DATASET, }, saAttachRevenueLinesSubjectArea: { description: "SA Attach revenue-line XSA dataset reused by the revenue-line view.", resolve: () => SA_ATTACH_REVENUE_LINES_DATASET, }, saAttachInvolvementBucket: { description: "SA Attach CASE expression that classifies my-team, other, or no presales involvement.", resolve: () => buildSaAttachInvolvementBucketExpr(), }, }; const PARAMETER_CATALOG = [ { name: "catalog", cli: "--catalog", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "Return one JSON payload with views, intents, entities, fields, macros, parameters, and script metadata.", }, { name: "check-auth", cli: "--check-auth", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["auth", "healthcheck"], default: false, description: "Validate the saved Oracle DV session without opening the browser.", }, { name: "list-views", cli: "--list-views", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "List built-in views with fields, entities, and parameter contracts.", }, { name: "describe-view", cli: "--describe-view", kind: "string", valueLabel: "", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], description: "Describe one built-in view by name.", examples: ["--describe-view opportunity-details"], }, { name: "list-intents", cli: "--list-intents", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "List recurring business-intent shortcuts.", }, { name: "describe-intent", cli: "--describe-intent", kind: "string", valueLabel: "", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], description: "Describe one intent and its parameter contract.", examples: ["--describe-intent opportunities-close-month"], }, { name: "list-entities", cli: "--list-entities", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "List logical entities and the views that expose them.", }, { name: "list-fields", cli: "--list-fields", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "List the local logical-field catalog.", }, { name: "describe-field", cli: "--describe-field", kind: "string", valueLabel: "", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], description: "Describe one field alias and its Oracle expression.", examples: ["--describe-field closeDate"], }, { name: "list-parameters", cli: "--list-parameters", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "List the full CLI parameter catalog for the skill scripts.", }, { name: "describe-parameter", cli: "--describe-parameter", kind: "string", valueLabel: "", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], description: "Describe one parameter by bare name or CLI flag.", examples: ["--describe-parameter resource", "--describe-parameter --from-date"], }, { name: "list-scripts", cli: "--list-scripts", kind: "flag", appliesTo: ["fetch-sales-intelligence.mjs"], modes: ["discovery"], default: false, description: "List the runnable scripts bundled in this skill.", }, { name: "describe-script", cli: "--describe-script", kind: "string", valueLabel: "