UNPKG

n8n-nodes-imap-ai

Version:

Simplified IMAP node for n8n with AI-agent support. Clean and modular email and mailbox management for automation workflows.

57 lines 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteMailboxOperation = void 0; const n8n_workflow_1 = require("n8n-workflow"); const SearchFieldParameters_1 = require("../../../utils/SearchFieldParameters"); exports.deleteMailboxOperation = { operation: { name: 'Delete', value: 'deleteMailbox', description: 'Delete empty mailbox folders for cleanup and organization. Perfect for AI agents to automatically remove obsolete folders, clean up temporary directories, or maintain organized folder structures.', }, parameters: [ { ...SearchFieldParameters_1.parameterSelectMailbox, description: 'Select the mailbox to delete. AI agents can specify folders like: Old-Projects, Temp, Archive-2023, or other obsolete folders.', default: "={{ $fromAI('folder_to_delete', 'Name of the mailbox/folder to delete') }}", }, { displayName: '⚠️ CRITICAL WARNING: This operation will permanently delete the selected mailbox and ALL its contents. This action CANNOT be undone. AI agents should verify folder is empty or backed up before deletion.', name: 'warning', type: 'notice', default: '', }, { displayName: 'Confirm Deletion', name: 'confirmDeletion', type: 'boolean', default: false, description: 'Whether to confirm that the mailbox should be permanently deleted. AI must explicitly confirm deletion.', required: true, }, ], async executeImapAction(context, itemIndex, client) { var _a; const returnData = []; const mailboxPath = (0, SearchFieldParameters_1.getMailboxPathFromNodeParameter)(context, itemIndex); const confirmDeletion = context.getNodeParameter('confirmDeletion', itemIndex); if (!confirmDeletion) { throw new n8n_workflow_1.NodeApiError(context.getNode(), {}, { message: `Mailbox deletion cancelled: confirmation required. Set confirmDeletion to true to delete mailbox "${mailboxPath}".`, }); } (_a = context.logger) === null || _a === void 0 ? void 0 : _a.info(`Deleting mailbox "${mailboxPath}"`); const imapResp = await client.mailboxDelete(mailboxPath); const item_json = JSON.parse(JSON.stringify(imapResp)); item_json.operation = 'deleteMailbox'; item_json.deletedMailbox = mailboxPath; item_json.success = true; item_json.deletedAt = new Date().toISOString(); item_json.warning = 'Mailbox and all contents permanently deleted'; returnData.push({ json: item_json, }); return returnData; }, }; //# sourceMappingURL=MailboxDelete.js.map