UNPKG

n8n-nodes-pdf-accessibility

Version:

AI-powered PDF accessibility automation for N8N - comprehensive WCAG compliance analysis, intelligent remediation, and professional audit reporting with 5 integrated accessibility tools

69 lines (68 loc) 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AiUtils = void 0; const providers_1 = require("../providers"); class AiUtils { /** * Analyzes PDF content for accessibility issues using the specified LLM provider */ static async analyzeAccessibility(context, extractedText, documentInfo, providerType, credentialType, options) { try { const credentials = await context.getCredentials(credentialType); if (!credentials) { throw new Error(`No credentials found for ${credentialType}`); } const provider = providers_1.LLMProviderFactory.createProvider(providerType, { apiKey: credentials.apiKey, baseUrl: credentials.baseUrl, model: credentials.defaultModel, ...credentials, }); return await provider.analyzeAccessibility(extractedText, documentInfo, options); } catch (error) { throw new Error(`AI Analysis failed: ${error instanceof Error ? error.message : String(error)}`); } } /** * Validates LLM provider credentials */ static async validateCredentials(context, providerType, credentialType) { try { const credentials = await context.getCredentials(credentialType); if (!credentials) { return false; } const provider = providers_1.LLMProviderFactory.createProvider(providerType, { apiKey: credentials.apiKey, baseUrl: credentials.baseUrl, model: credentials.defaultModel, ...credentials, }); return await provider.validateCredentials(); } catch (error) { return false; } } /** * Gets available models for a provider type */ static getProviderModels(providerType) { return providers_1.LLMProviderFactory.getProviderModels(providerType); } /** * Gets supported providers */ static getSupportedProviders() { return providers_1.LLMProviderFactory.getSupportedProviders(); } /** * Estimates token count for cost calculation */ static estimateTokens(text) { // Rough estimation: ~4 characters per token return Math.ceil(text.length / 4); } } exports.AiUtils = AiUtils;