// src/commands/woAttachments-web.js import { listWorkOrderAttachments } from '../integrations/serviceChannel/attachments.js'; import { logger } from '../utils/logger.js'; export async function handleWoAttachmentsWeb(woId) { logger('wo-attachments-web', `Handling web request for attachments on WO ${woId}`); try { const attachments = await listWorkOrderAttachments(woId); const result = { success: true, woId: parseInt(woId), count: attachments.length, attachments: attachments.map(att => ({ id: att.Id, fileName: att.Name || `attachment_${att.Id}`, contentType: att.ContentType || 'application/octet-stream', downloadUri: att.Uri })) }; logger('wo-attachments-web', `Successfully returned ${attachments.length} attachments for WO ${woId}`); return result; } catch (err) { logger('wo-attachments-web', `Error fetching attachments for WO ${woId}: ${err.message}`, 'error'); return { success: false, error: err.message }; } }