sfcc-dev-mcp
Version:
MCP server for Salesforce B2C Commerce Cloud development assistance including logs, debugging, and development tools
46 lines • 1.47 kB
JavaScript
import { BaseToolHandler } from './base-handler.js';
import { ClientFactory } from './client-factory.js';
/**
* Abstract base class for log-related tool handlers
* Extends the generic config-driven handler with log-specific functionality
*/
export class AbstractLogToolHandler extends BaseToolHandler {
logClient = null;
clientFactory;
constructor(context, subLoggerName) {
super(context, subLoggerName);
this.clientFactory = new ClientFactory(context, this.logger);
}
async onInitialize() {
this.logClient = this.clientFactory.createLogClient();
if (this.logClient) {
this.logger.debug('Log client initialized');
}
}
async onDispose() {
this.logClient = null;
this.logger.debug('Log client disposed');
}
/**
* Get the log client with proper error handling
* Eliminates repetitive null checks in handlers
*/
getLogClient() {
if (!this.logClient) {
throw new Error(ClientFactory.getClientRequiredError('Log'));
}
return this.logClient;
}
/**
* Create execution context for log tools
* Provides access to log client and handler context
*/
async createExecutionContext() {
return {
handlerContext: this.context,
logger: this.logger,
logClient: this.getLogClient(),
};
}
}
//# sourceMappingURL=abstract-log-tool-handler.js.map