n8n-bookstack-agent-tool
Version:
Comprehensive BookStack API integration tool for n8n AI Agent with MCP framework compatibility
43 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BookStackConfigValidator = void 0;
class BookStackConfigValidator {
static validate(config) {
if (!config.baseUrl) {
throw new Error('BookStack base URL is required');
}
if (!config.baseUrl.startsWith('http://') && !config.baseUrl.startsWith('https://')) {
throw new Error('BookStack base URL must start with http:// or https://');
}
if (!config.authType) {
throw new Error('Authentication type is required (bearer or session)');
}
if (config.authType === 'bearer' && !config.token) {
throw new Error('Bearer token is required when using bearer authentication');
}
if (config.authType === 'session' && !config.sessionCookie) {
throw new Error('Session cookie is required when using session authentication');
}
if (config.timeout && (config.timeout < 1000 || config.timeout > 300000)) {
throw new Error('Timeout must be between 1000ms and 300000ms');
}
if (config.retryAttempts && (config.retryAttempts < 0 || config.retryAttempts > 10)) {
throw new Error('Retry attempts must be between 0 and 10');
}
if (config.retryDelay && (config.retryDelay < 100 || config.retryDelay > 10000)) {
throw new Error('Retry delay must be between 100ms and 10000ms');
}
}
static createDefault(baseUrl, token) {
return {
baseUrl: baseUrl.replace(/\/$/, ''),
authType: 'bearer',
token,
timeout: 30000,
retryAttempts: 3,
retryDelay: 1000
};
}
}
exports.BookStackConfigValidator = BookStackConfigValidator;
//# sourceMappingURL=config.js.map