ds-sfcoe-ailabs
Version:
AI-powered code review tool with static analysis integration for comprehensive code quality assessment.
150 lines (149 loc) • 4.6 kB
TypeScript
/**
* @fileoverview Utility types and exports for the common utilities module
* Provides type definitions for DocuSign analysis, table entries, and observability configuration
*/
/**
* Represents a DocuSign-specific issue found during code analysis
*
* @example
* ```typescript
* const issue: DocuSignIssue = {
* lineNumber: 42,
* ruleType: 'DML_IN_LOOP',
* issue: 'DML statement found inside a loop'
* };
* ```
*/
export type DocuSignIssue = {
/** The line number where the issue was found */
lineNumber: number;
/** The type of rule violation detected */
ruleType: string;
/** Description of the issue found */
issue: string;
};
/**
* Represents a table entry for displaying analysis results
* Contains comprehensive information about a code issue and its suggested resolution
*
* @example
* ```typescript
* const entry: TableEntry = {
* className: 'AccountController',
* lineNumber: 25,
* ruleType: 'SOQL_IN_LOOP',
* issue: 'SOQL query inside for loop',
* suggestedFix: 'Move SOQL query outside the loop and use bulk processing'
* };
* ```
*/
export type TableEntry = {
/** The name of the class where the issue was found */
className: string;
/** The line number where the issue occurs */
lineNumber: number;
/** The type of rule that was violated */
ruleType: string;
/** Detailed description of the issue */
issue: string;
/** Recommended fix for the issue */
suggestedFix: string;
};
/**
* Configuration for Datadog logger integration
* Defines all necessary parameters for setting up structured logging with Datadog
*
* @example
* ```typescript
* const loggerConfig: DatadogLoggerConfig = {
* apiKey: 'your-datadog-api-key',
* service: 'ai-pr-review',
* environment: 'production',
* logLevel: 'info',
* customMeta: { version: '1.0.0' }
* };
* ```
*/
export type DatadogLoggerConfig = {
/** Datadog API key for authentication */
apiKey: string;
/** Source identifier for logs (default: 'salesforce') */
ddsource?: string;
/** Hostname for the logging instance */
hostname?: string;
/** Service name for log categorization */
service?: string;
/** Environment identifier (e.g., 'production', 'staging') */
environment?: string;
/** Minimum log level to capture */
logLevel?: string;
/** Custom metadata to be included in all logs */
customMeta?: Record<string, unknown>;
};
/**
* Configuration for Datadog metrics integration
* Defines parameters for collecting and sending application metrics to Datadog
*
* @example
* ```typescript
* const metricsConfig: DatadogMetricsConfig = {
* apiKey: 'your-datadog-api-key',
* host: 'localhost',
* prefix: 'ai-pr-review.',
* globalTags: ['service:pr-review', 'env:production'],
* flushIntervalSeconds: 10
* };
* ```
*/
export type DatadogMetricsConfig = {
/** Datadog API key for authentication */
apiKey: string;
/** Hostname for metrics submission */
host?: string;
/** Port number for metrics connection */
port?: number;
/** Prefix to be added to all metric names */
prefix?: string;
/** Tags to be applied to individual metrics */
tags?: string[];
/** Global tags applied to all metrics */
globalTags?: string[];
/** Enable mock mode for testing (metrics won't be sent) */
mock?: boolean;
/** Global prefix for all metrics */
globalPrefix?: string;
/** Number of metrics to buffer before sending */
bufferSize?: number;
/** Interval in seconds between metric flushes */
flushIntervalSeconds?: number;
};
/**
* Combined configuration for observability components
* Bundles both logging and metrics configuration for centralized setup
*
* @example
* ```typescript
* const observabilityConfig: ObservabilityConfig = {
* logger: {
* apiKey: 'your-api-key',
* service: 'ai-pr-review'
* },
* metrics: {
* apiKey: 'your-api-key',
* prefix: 'ai-pr-review.'
* }
* };
* ```
*/
export type ObservabilityConfig = {
/** Configuration for the logging system */
logger: DatadogLoggerConfig;
/** Configuration for the metrics system */
metrics: DatadogMetricsConfig;
};
export { FileUtils } from './fileUtils.js';
export { CodeAnalysisUtils } from './codeAnalysisUtils.js';
export { RuleUtils } from './ruleUtils.js';
export { DocuSignRuleUtils } from './docuSignRuleUtils.js';
export { TableEntryUtils } from './tableEntryUtils.js';
export { Logger, Metrics, ObservabilityInitializer } from './observability.js';