UNPKG

ds-sfcoe-ailabs

Version:

AI-powered code review tool with static analysis integration for comprehensive code quality assessment.

266 lines (265 loc) 10.2 kB
import { AIProviderType } from '../aiProvider/index.js'; /** * Supported AI providers mapping * Maps string identifiers to AIProviderType enum values * * @example * ```typescript * const provider = AI_PROVIDERS.OPENAI; // AIProviderType.OpenAI * ``` */ export declare const AI_PROVIDERS: Record<string, AIProviderType>; /** * Default GitHub bot identifier and comment header/footer configuration * Contains standard identifiers and templates for GitHub PR comments * * @example * ```typescript * const comment = `${GITHUB_BOT_IDENTIFIER_DEFAULTS.COMMENT_HEADER}\n\nReview content\n\n${GITHUB_BOT_IDENTIFIER_DEFAULTS.COMMENT_FOOTER}`; * ``` */ export declare const GITHUB_BOT_IDENTIFIER_DEFAULTS: { IDENTIFIER: string; COMMENT_HEADER: string; USER_AGENT: string; COMMENT_FOOTER: string; }; /** * Default GitHub REST API configuration values * Contains standard API endpoints, headers, and error messages for GitHub integration * * @example * ```typescript * const apiUrl = `${GITHUB_API_DEFAULTS.PR_BASE_URL}/${owner}/${repo}/pulls`; * ``` */ export declare const GITHUB_API_DEFAULTS: { readonly PR_BASE_URL: "https://api.github.com/repos"; readonly USER_AGENT: string; readonly API_VERSION: "2022-11-28"; readonly ACCEPT_HEADER: "application/vnd.github+json"; readonly START_SIDE: "RIGHT"; readonly RESPONSE_TYPE: "json"; readonly SAML_ERROR_MESSAGE: "🔒 GitHub SAML SSO Required! Your organization requires SAML Single Sign-On authentication for Personal Access Tokens.\n\n SOLUTION STEPS:\n 1. Go to your Personal Access Tokens page: https://github.com/settings/tokens\n 2. Find your token and click \"Configure SSO\" next to it\n 3. Authorize the token for your organization\n 4. Click \"Authorize\" to grant SAML SSO access\n\n Alternative: Create a new token and immediately authorize it for SSO:\n 1. Create new token: https://github.com/settings/tokens/new\n 2. Select required scopes (repo for private repos, public_repo for public)\n 3. Click \"Configure SSO\" and authorize for organization\n\n Documentation: https://docs.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/"; }; /** * Supported file extensions for code analysis by language/platform * Organizes file extensions by technology stack for targeted analysis * * @example * ```typescript * const isApexFile = SUPPORTED_FILE_EXTENSIONS.APEX.includes('.cls'); * const jsExtensions = SUPPORTED_FILE_EXTENSIONS.JAVASCRIPT; * ``` */ export declare const SUPPORTED_FILE_EXTENSIONS: { readonly APEX: readonly [".cls", ".trigger"]; readonly JAVASCRIPT: readonly [".js", ".mjs", ".cjs"]; readonly TYPESCRIPT: readonly [".ts"]; readonly HTML: readonly [".html"]; readonly CSS: readonly [".css"]; readonly XML: readonly [".xml"]; readonly AURA: readonly [".cmp"]; readonly METADATA: readonly [".xml", ".json", ".yaml", ".yml"]; readonly PLSQL: readonly [".sql", ".pks", ".pkb", ".prc", ".fnc", ".trg", ".typ", ".tps", ".tpb"]; readonly VISUALFORCE: readonly [".page", ".component"]; readonly JAVA: readonly [".java"]; }; /** * Directories to exclude from analysis * List of common directories that should be skipped during code analysis * * @example * ```typescript * const shouldExclude = EXCLUDED_DIRECTORIES.includes('node_modules'); * ``` */ export declare const EXCLUDED_DIRECTORIES: string[]; /** * Test framework patterns and identifiers for Apex testing * Contains patterns used to identify test files and deprecated testing frameworks * * @example * ```typescript * const isTestFile = content.includes(TEST_PATTERNS.APEX_TEST_ANNOTATION); * const usesOldFramework = content.includes(TEST_PATTERNS.SOBJECT_MOCKER); * ``` */ export declare const TEST_PATTERNS: { readonly APEX_TEST_ANNOTATION: "@isTest"; readonly SOBJECT_MOCKER: "SObjectMocker"; readonly CLASS_MOCKER: "ClassMocker"; readonly GENERATE_MOCK_SOBJECT: "generateMockSObject"; readonly TEST_FILE_PATTERN: "test"; }; /** * Default Datadog configuration values for observability * Contains standard settings for logging and metrics integration with Datadog * * @example * ```typescript * const logConfig = { * service: DATADOG_DEFAULT_CONSTANTS.service, * environment: DATADOG_DEFAULT_CONSTANTS.environment * }; * ``` */ export declare const DATADOG_DEFAULT_CONSTANTS: { readonly ddsource: "AIPRReview"; readonly hostname: "sfcoe-aipr-review"; readonly service: "sfcoe-aipr-review"; readonly prefix: "sfcoe_aipr_review."; readonly environment: "development"; readonly logLevel: "debug"; readonly timestampFormat: "MMM-DD-YYYY HH:mm:ss"; readonly observabilityFlags: readonly ["pull-request-id", "ai-provider", "git-provider", "git-owner", "git-repo"]; }; /** * Default patterns for JavaScript code analysis * Predefined patterns to detect common JavaScript issues and violations * * @example * ```typescript * const consolePattern = JS_PATTERNS.find(p => p.pattern === 'console.log'); * console.log(consolePattern.suggestedFix); * ``` */ export declare const JS_PATTERNS: { pattern: string; ruleType: string; issue: string; suggestedFix: string; ruleId: string; }[]; /** * Package and message bundle identifiers * Contains package metadata and command identifiers * * @example * ```typescript * console.log(`Running ${PACKAGE_CONSTANTS.NAME} package`); * const command = PACKAGE_CONSTANTS.REVIEW_COMMAND; * ``` */ export declare const PACKAGE_CONSTANTS: { readonly NAME: "ds-sfcoe-ailabs"; readonly REVIEW_COMMAND: "ks.review.diff"; }; /** * Default values for command flags and configuration * Provides fallback values for CLI command options and API settings * * @example * ```typescript * const fromRef = flags.from || COMMAND_DEFAULTS.GIT_FROM_REF; * const aiProvider = flags.aiProvider || COMMAND_DEFAULTS.AI_PROVIDER; * ``` */ export declare const COMMAND_DEFAULTS: { readonly GIT_FROM_REF: "HEAD~1"; readonly GIT_TO_REF: "HEAD"; readonly AI_PROVIDER: AIProviderType.AzureOpenAI; readonly GIT_PROVIDER: "GitHub"; readonly AI_MODEL: "gpt-4o-mini-eastus2"; readonly AI_API_ENDPOINT: "https://dts-apigw-sandbox.docusignhq.com/"; readonly AI_API_VERSION: "2024-08-01-preview"; readonly SCA_RULESET: "../../common/contextProviders/scat/sf-code-analyzer-ruleset.yml"; readonly PMD_RULESET: "../../common/contextProviders/scat/pmd-ruleset.xml"; readonly DEFAULT_MAX_TOKENS: 4096; readonly DEFAULT_PROMPT_TEMPLATE: "$prompt\n\n# Code Snippet:\n$codeSnippet\n\n# Hints:\n$hintsText"; readonly DEFAULT_SARIF_FILE_NAME: "results.sarif"; readonly SF_CODE_ANALYZER_LOGS_FOLDER: "code-analyzer-logs"; }; /** * Default values for review command hints and messages * Contains fallback values and templates for review output formatting * * @example * ```typescript * const ruleId = hint.ruleId || REVIEW_COMMAND_HINTS_DEFAULTS.RULE_ID; * const tableHeader = REVIEW_COMMAND_HINTS_DEFAULTS.AI_ANALYSIS_TABLE_HEADERS; * ``` */ export declare const REVIEW_COMMAND_HINTS_DEFAULTS: { RULE_ID: string; MESSAGE: string; SUGGESTION: string; SUGGESTION_RULE_TYPE: string; RULE_TYPE: string; FILE_NAME: string; LINE_NUMBER: number; AI_ANALYSIS_TABLE_HEADERS: string; }; /** * Regex pattern to match file extensions * Used to extract the last file extension from file paths * * @example * ```typescript * const extension = 'file.cls'.match(LAST_EXTENSION_REGEX)?.[0]; // '.cls' * ``` */ export declare const LAST_EXTENSION_REGEX: RegExp; /** * DocuSign-specific issues and patterns for code analysis * Defines organization-specific rules and their corresponding messages and fixes * * @example * ```typescript * const testIssue = DOCUSIGN_SPECIFIC_ISSUES.TEST_FRAMEWORK; * console.log(testIssue.suggestedFix); * ``` */ export declare const DOCUSIGN_SPECIFIC_ISSUES: { readonly TEST_FRAMEWORK: { readonly ruleType: "Docusign Specific"; readonly issue: "Using old test framework which takes huge time to run"; readonly suggestedFix: "[Use SObjectMocker, ClassMocker, or generateMockSObject.](https://docusign.atlassian.net/wiki/spaces/EA/pages/720143853/DS+Apex+Test+-+Overview)"; }; readonly GLOBAL_DESCRIBE_USAGE: { readonly ruleType: "Docusign Specific"; readonly issue: "Using Schema.getGlobalDescribe() which has performance issues"; readonly suggestedFix: "[Use COE_SchemaUtils framework.](https://docusign.atlassian.net/wiki/spaces/EA/pages/155880835/Better+getGlobalDescribe)"; }; readonly TRANSACTION_LOGGER_MISSING: { readonly ruleType: "Docusign Specific"; readonly issue: "New Apex class does not have any reference to TransactionLogger methods"; readonly suggestedFix: "[Add TransactionLogger methods for better tracking and observability.](https://docusign.atlassian.net/wiki/x/HwPaGQ)"; }; }; /** * Supported Salesforce file extensions for platform-specific analysis * List of file extensions commonly used in Salesforce development * * @example * ```typescript * const isSalesforceFile = SUPPORTED_SALESFORCE_EXTENSIONS.includes('.cls'); * ``` */ export declare const SUPPORTED_SALESFORCE_EXTENSIONS: string[]; /** * Mapping of rule types to human-readable categories * Maps linter rule IDs to descriptive category names for better user understanding * * @example * ```typescript * const category = RULE_TYPE_MAP['no-var']; // 'JavaScript Best Practices' * const unknownRule = RULE_TYPE_MAP['unknown-rule'] || 'General'; * ``` */ export declare const RULE_TYPE_MAP: { [key: string]: string; }; /** * Suggested fixes for common code issues * Maps rule IDs to actionable fix descriptions for developers * * @example * ```typescript * const fix = SUGGESTED_FIXES['no-var']; // 'Replace var with let or const for block scoping' * const defaultFix = SUGGESTED_FIXES[ruleId] || 'Review and refactor as needed'; * ``` */ export declare const SUGGESTED_FIXES: { [key: string]: string; };