UNPKG

n8n-nodes-magic-dev

Version:

๐Ÿช„ Magic Dev - Revolutionary community n8n node: AI Generation, Creator Hub, Quest Unlock, Market, P2P Magic Inbox (send & receive)!

338 lines (333 loc) โ€ข 25.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MagicDev = void 0; class MagicDev { constructor() { this.description = { displayName: '๐Ÿช„ Magic Dev', name: 'magicDev', icon: 'fa:gift', group: ['transform'], version: 6.3, subtitle: '={{$parameter["mode"] || "Choose Your Magic"}}', description: ` ๐ŸŒŸ Revolutionary workflow ecosystem: AI Generation, Creator Hub, Quest Unlock, Community Database & Magic Inbox SEND (P2P/Forum) --- IMPORTANT! For Magic Market Teleport mapping to work, your Google Sheet column containing the workflow JSON must be named: WORKFLOW (all uppercase, no spaces). If the column name is not exactly "WORKFLOW", mapping & teleportation will not work. --- `, defaults: { name: '๐Ÿช„ Magic Dev 6.3', color: '#2362ba' }, inputs: ["main" /* NodeConnectionType.Main */], outputs: ["main" /* NodeConnectionType.Main */], properties: [ { displayName: '๐Ÿช„ Magic Dev 6.3 - Ultimate Workflow Ecosystem', name: 'magicGuide', type: 'string', typeOptions: { rows: 18 }, default: `๐ŸŒŸ MAGIC DEV 6.3 - All classic features + Magic Inbox Send! ๐Ÿค– Magic Mapping โ†’ Prompt, URLs, API keys, OpenRouter, POST teleport workflow to your instance. ๐ŸŽ Creator Mapping โ†’ Get a random (premium) creator workflow via POST. ๐Ÿ”‘ Quest Mapping โ†’ Unlock premium workflow via secret code (POST). ๐Ÿ—ƒ๏ธ Magic Market โ†’ PUBLISH: POST your workflow to Google Sheets | SEARCH: POST search by keywords/community DB. ๐Ÿ“ค Magic Inbox SEND: Send message or workflow via POST to a peer or public forum node (logs returned). โญ FEEDBACK: Optional rating system (1-20 stars) + comments IMPORTANT: For Magic Market Teleport mapping to work, your Google Sheet column containing the workflow JSON must be named: WORKFLOW (all uppercase, no spaces). `, description: 'Complete Magic Dev guide with clear mapping system' }, { displayName: '๐ŸŽฏ Choose Your Magic Mode', name: 'mode', type: 'options', options: [ { name: '๐Ÿค– Magic Mapping (AI Generation)', value: 'ai_generation' }, { name: '๐ŸŽ Creator premium Mapping (Community Hub)', value: 'creator_teleport' }, { name: '๐Ÿ”‘ Quest Mapping (Premium Unlock)', value: 'quest_unlock' }, { name: '๐Ÿ—ƒ๏ธ Magic Market (Community Database)', value: 'magic_market' }, { name: '๐Ÿ“ค Magic Inbox Send (P2P/Forum)', value: 'magic_inbox_send' }, ], default: 'ai_generation' }, // ---- AI GENERATION ---- { displayName: '๐ŸŒ N8N Instance URL', name: 'aiInstanceUrl', type: 'string', required: true, displayOptions: { show: { mode: ['ai_generation'] } }, default: '', placeholder: 'https://your-n8n-instance.com' }, { displayName: '๐Ÿ”‘ N8N API Key', name: 'aiApiKey', type: 'string', typeOptions: { password: true }, required: true, displayOptions: { show: { mode: ['ai_generation'] } }, default: '', placeholder: 'n8n_api_xxx' }, { displayName: '๐Ÿค– OpenRouter API Key', name: 'aiOpenrouterKey', type: 'string', typeOptions: { password: true }, required: true, displayOptions: { show: { mode: ['ai_generation'] } }, default: '', placeholder: 'sk-or-v1-xxx' }, { displayName: '๐Ÿ’ญ Workflow Prompt', name: 'aiPrompt', type: 'string', typeOptions: { rows: 4 }, displayOptions: { show: { mode: ['ai_generation'] } }, default: '', placeholder: 'Create an email automation system...' }, { displayName: '๐ŸŽ›๏ธ Complexity Level', name: 'aiComplexity', type: 'options', displayOptions: { show: { mode: ['ai_generation'] } }, options: [ { name: 'โšก Simple & Fast', value: 'simple' }, { name: '๐ŸŽฏ Balanced & Functional', value: 'balanced' }, { name: '๐Ÿš€ Advanced & Feature-Rich', value: 'advanced' } ], default: 'balanced' }, // ---- CREATOR MAPPING ---- { displayName: '๐ŸŒ N8N Instance URL', name: 'creatorInstanceUrl', type: 'string', required: true, displayOptions: { show: { mode: ['creator_teleport'] } }, default: '', placeholder: 'https://your-n8n-instance.com' }, { displayName: '๐Ÿ”‘ N8N API Key', name: 'creatorApiKey', type: 'string', typeOptions: { password: true }, required: true, displayOptions: { show: { mode: ['creator_teleport'] } }, default: '', placeholder: 'n8n_api_xxx' }, { displayName: '๐ŸŽฏ Category Preference', name: 'creatorCategory', type: 'options', displayOptions: { show: { mode: ['creator_teleport'] } }, options: [ { name: '๐ŸŽฒ Surprise Me (Random)', value: 'random' }, { name: '๐Ÿ“ง Email & Communication', value: 'email' }, { name: '๐Ÿ“Š Data & Analytics', value: 'data' }, { name: '๐Ÿ”„ Automation & Tasks', value: 'automation' }, { name: '๐Ÿ›ก๏ธ Security & Monitoring', value: 'security' }, { name: '๐ŸŽจ Creative & Content', value: 'creative' }, { name: '๐ŸŒฟ Biomimetic (Golden Ratio)', value: 'biomimetic' } ], default: 'random' }, // ---- QUEST MAPPING ---- { displayName: '๐ŸŒ N8N Instance URL', name: 'questInstanceUrl', type: 'string', required: true, displayOptions: { show: { mode: ['quest_unlock'] } }, default: '', placeholder: 'https://your-n8n-instance.com' }, { displayName: '๐Ÿ”‘ N8N API Key', name: 'questApiKey', type: 'string', typeOptions: { password: true }, required: true, displayOptions: { show: { mode: ['quest_unlock'] } }, default: '', placeholder: 'n8n_api_xxx' }, { displayName: '๐ŸŽซ Quest Secret Code', name: 'questCode', type: 'string', required: true, displayOptions: { show: { mode: ['quest_unlock'] } }, default: '', placeholder: 'GOLDEN_RATIO_2025,...' }, { displayName: '๐Ÿ“ Code Source', name: 'questSource', type: 'options', displayOptions: { show: { mode: ['quest_unlock'] } }, options: [ { name: '๐Ÿ“ฑ Telegram Community', value: 'telegram' }, { name: '๐ŸŽฎ Discord Server', value: 'discord' }, { name: '๐Ÿ“ง Newsletter', value: 'newsletter' }, { name: '๐ŸŽ‰ Special Event', value: 'event' }, { name: '๐ŸŒฟ Creator Mapping Workflows', value: 'creator_notes' }, { name: '๐Ÿ” Hidden URL Discovery', value: 'hidden_url' }, { name: 'โ“ Other Source', value: 'other' } ], default: 'creator_notes' }, // ---- MAGIC MARKET ---- { displayName: '๐Ÿ—ƒ๏ธ Magic Market Action', name: 'marketAction', type: 'options', displayOptions: { show: { mode: ['magic_market'] } }, options: [ { name: '๐Ÿ“ค PUBLISH Workflow', value: 'post' }, { name: '๐Ÿ” SEARCH Workflows', value: 'search' } ], default: 'post' }, { displayName: '๐Ÿ”— Google Sheets URL (Public)', name: 'marketPostGoogleSheetUrl', type: 'string', required: true, displayOptions: { show: { mode: ['magic_market'], marketAction: ['post'] } }, default: '', placeholder: 'https://docs.google.com/spreadsheets/d/xxx/edit?usp=sharing' }, { displayName: '๐Ÿ“ Workflow Description', name: 'marketPostDescription', type: 'string', typeOptions: { rows: 6 }, required: true, displayOptions: { show: { mode: ['magic_market'], marketAction: ['post'] } }, default: '', placeholder: 'Using the Google Sheet link, ...' }, { displayName: '๐Ÿ” Search Keywords', name: 'marketResearchKeywords', type: 'string', required: true, displayOptions: { show: { mode: ['magic_market'], marketAction: ['search'] } }, default: '', placeholder: 'email automation, golden ratio, webhook...' }, { displayName: '๐Ÿท๏ธ Category Filter', name: 'marketResearchCategory', type: 'options', displayOptions: { show: { mode: ['magic_market'], marketAction: ['search'] } }, options: [ { name: '๐ŸŒŸ All Categories', value: 'all' }, { name: '๐Ÿ“ง Email & Communication', value: 'email' }, { name: '๐Ÿ“Š Data & Analytics', value: 'data' }, { name: '๐Ÿ”„ Automation & Tasks', value: 'automation' }, { name: '๐Ÿ›ก๏ธ Security & Monitoring', value: 'security' }, { name: '๐ŸŽจ Creative & Content', value: 'creative' }, { name: '๐ŸŒฟ Biomimetic (Golden Ratio)', value: 'biomimetic' } ], default: 'all' }, { displayName: 'โญ Minimum Rating', name: 'marketResearchMinRating', type: 'number', displayOptions: { show: { mode: ['magic_market'], marketAction: ['search'] } }, default: 15, typeOptions: { minValue: 1, maxValue: 20 } }, { displayName: 'โšก Teleport Result', name: 'marketTeleportEnabled', type: 'boolean', displayOptions: { show: { mode: ['magic_market'], marketAction: ['search'] } }, default: false }, { displayName: '๐ŸŒ Destination Instance URL', name: 'marketTeleportInstanceUrl', type: 'string', required: true, displayOptions: { show: { mode: ['magic_market'], marketAction: ['search'], marketTeleportEnabled: [true] } }, default: '', placeholder: 'https://your-n8n-instance.com' }, { displayName: '๐Ÿ”‘ Destination API Key', name: 'marketTeleportApiKey', type: 'string', typeOptions: { password: true }, required: true, displayOptions: { show: { mode: ['magic_market'], marketAction: ['search'], marketTeleportEnabled: [true] } }, default: '', placeholder: 'n8n_api_xxx' }, // ---- MAGIC INBOX SEND (P2P/Forum) ---- { displayName: 'โœจ Send to a forum', name: 'sendToForum', type: 'boolean', default: false, displayOptions: { show: { mode: ['magic_inbox_send'] } } }, { displayName: '๐ŸŒ Destination URL', name: 'destinationUrl', type: 'string', displayOptions: { show: { mode: ['magic_inbox_send'], sendToForum: [false] } }, default: '', placeholder: 'https://target-instance.com/webhook/magic-inbox' }, { displayName: '๐Ÿ—ฃ๏ธ Forum', name: 'forum', type: 'options', displayOptions: { show: { mode: ['magic_inbox_send'], sendToForum: [true] } }, options: [ { name: '๐Ÿ’ฌ General', value: 'general' }, { name: '๐Ÿ’ผ Job', value: 'job' }, { name: '๐Ÿ†˜ Help', value: 'help' }, { name: '๐Ÿค Business', value: 'business' } ], default: '' }, { displayName: '๐Ÿ”‘ Destination API Key (Optional)', name: 'destinationApiKey', type: 'string', typeOptions: { password: true }, default: '', displayOptions: { show: { mode: ['magic_inbox_send'] } } }, { displayName: '๐Ÿ‘ค Your Identity', name: 'senderId', type: 'string', required: true, default: '', displayOptions: { show: { mode: ['magic_inbox_send'] } }, placeholder: 'your@email.com or nickname' }, { displayName: 'โœ‰๏ธ Message', name: 'sendMessage', type: 'string', typeOptions: { rows: 4 }, displayOptions: { show: { mode: ['magic_inbox_send'] } }, default: '', placeholder: 'Hello...' }, { displayName: '๐Ÿ“ฆ Content Type', name: 'contentType', type: 'options', options: [ { name: '๐Ÿ’ฌ Message Only', value: 'message_only' }, { name: '๐Ÿ”„ Message + Workflow', value: 'workflow_with_message' } ], default: 'message_only', displayOptions: { show: { mode: ['magic_inbox_send'] } } }, { displayName: '๐Ÿท๏ธ Workflow Name', name: 'workflowName', type: 'string', displayOptions: { show: { mode: ['magic_inbox_send'], contentType: ['workflow_with_message'] } }, default: '', placeholder: 'My_Workflow' }, { displayName: '๐Ÿ—‚๏ธ Workflow JSON', name: 'workflowJson', type: 'string', typeOptions: { rows: 8 }, displayOptions: { show: { mode: ['magic_inbox_send'], contentType: ['workflow_with_message'] } }, default: '', placeholder: '{"nodes":[...],"connections":{...},"settings":{...}}' }, { displayName: '๐Ÿ“’ Send Address Book', name: 'addressBookSend', type: 'string', typeOptions: { rows: 6 }, default: '', displayOptions: { show: { mode: ['magic_inbox_send'] } } }, { displayName: 'โฑ๏ธ Timeout (seconds)', name: 'timeout', type: 'number', default: 30, displayOptions: { show: { mode: ['magic_inbox_send'] } } }, { displayName: '๐Ÿ”„ Retry on Failure', name: 'retryOnFailure', type: 'boolean', default: true, displayOptions: { show: { mode: ['magic_inbox_send'] } } }, { displayName: '๐Ÿ”ข Max Retries', name: 'maxRetries', type: 'number', default: 3, displayOptions: { show: { mode: ['magic_inbox_send'], retryOnFailure: [true] } } }, { displayName: '๐Ÿ” Debug Mode', name: 'debugMode', type: 'boolean', default: false, displayOptions: { show: { mode: ['magic_inbox_send'] } } }, // ---- FEEDBACK ---- { displayName: 'โญ Rate Your Experience (Optional)', name: 'userRating', type: 'options', options: Array.from({ length: 20 }, (_, i) => ({ name: `โญ ${i + 1}`, value: i + 1 })), default: 10 }, { displayName: '๐Ÿ’ญ Your Comments (Optional)', name: 'userComments', type: 'string', typeOptions: { rows: 3 }, default: '', placeholder: 'Share your thoughts about Magic Dev...' } ] }; } async execute() { const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { try { const mode = this.getNodeParameter('mode', i, 'ai_generation'); let payload = { mode, timestamp: new Date().toISOString() }; const userRating = this.getNodeParameter('userRating', i, null); const userComments = this.getNodeParameter('userComments', i, ''); if (userRating !== null) { payload.feedback = { rating: userRating, comments: (userComments || '').toString().trim(), mode: mode, timestamp: new Date().toISOString() }; } // --- POST/TELEPORTS --- if (mode === 'ai_generation') { payload.aiInstanceUrl = this.getNodeParameter('aiInstanceUrl', i, ''); payload.aiApiKey = this.getNodeParameter('aiApiKey', i, ''); payload.aiOpenrouterKey = this.getNodeParameter('aiOpenrouterKey', i, ''); payload.aiPrompt = this.getNodeParameter('aiPrompt', i, ''); payload.aiComplexity = this.getNodeParameter('aiComplexity', i, 'balanced'); if (!payload.aiInstanceUrl || !payload.aiApiKey || !payload.aiOpenrouterKey) { throw new Error('AI Instance URL, AI API Key, and OpenRouter Key are required'); } } else if (mode === 'creator_teleport') { payload.creatorInstanceUrl = this.getNodeParameter('creatorInstanceUrl', i, ''); payload.creatorApiKey = this.getNodeParameter('creatorApiKey', i, ''); payload.creatorCategory = this.getNodeParameter('creatorCategory', i, 'random'); if (!payload.creatorInstanceUrl || !payload.creatorApiKey) { throw new Error('Creator Instance URL and Creator API Key are required'); } } else if (mode === 'quest_unlock') { payload.questInstanceUrl = this.getNodeParameter('questInstanceUrl', i, ''); payload.questApiKey = this.getNodeParameter('questApiKey', i, ''); payload.questCode = this.getNodeParameter('questCode', i, ''); payload.questSource = this.getNodeParameter('questSource', i, 'creator_notes'); if (!payload.questInstanceUrl || !payload.questApiKey || !payload.questCode) { throw new Error('Quest Instance URL, Quest API Key, and Quest Code are required'); } } else if (mode === 'magic_market') { const marketAction = this.getNodeParameter('marketAction', i, 'post'); payload.marketAction = marketAction; if (marketAction === 'post') { payload.marketPostGoogleSheetUrl = this.getNodeParameter('marketPostGoogleSheetUrl', i, ''); payload.marketPostDescription = this.getNodeParameter('marketPostDescription', i, ''); if (!payload.marketPostGoogleSheetUrl || !payload.marketPostDescription) { throw new Error('Google Sheet URL and Description are required for posting'); } } else if (marketAction === 'search') { payload.marketResearchKeywords = this.getNodeParameter('marketResearchKeywords', i, ''); payload.marketResearchCategory = this.getNodeParameter('marketResearchCategory', i, 'all'); payload.marketResearchMinRating = this.getNodeParameter('marketResearchMinRating', i, 15); payload.marketTeleportEnabled = this.getNodeParameter('marketTeleportEnabled', i, false); if (payload.marketTeleportEnabled) { payload.marketTeleportInstanceUrl = this.getNodeParameter('marketTeleportInstanceUrl', i, ''); payload.marketTeleportApiKey = this.getNodeParameter('marketTeleportApiKey', i, ''); if (!payload.marketTeleportInstanceUrl || !payload.marketTeleportApiKey) { throw new Error('Instance URL and API Key are required for workflow teleportation'); } } if (!payload.marketResearchKeywords) { throw new Error('Search keywords are required'); } } } else if (mode === 'magic_inbox_send') { const forumUrls = { general: 'https://n8n.srv740722.hstgr.cloud/webhook/magic-inbox/general', job: 'https://n8n.srv740722.hstgr.cloud/webhook/magic-inbox/job', help: 'https://n8n.srv740722.hstgr.cloud/webhook/magic-inbox/help', business: 'https://n8n.srv740722.hstgr.cloud/webhook/magic-inbox/business' }; const sendToForum = this.getNodeParameter('sendToForum', i, false); let destinationUrl = String(this.getNodeParameter('destinationUrl', i, '')).trim(); let forum = ''; if (sendToForum) { forum = this.getNodeParameter('forum', i, ''); destinationUrl = forumUrls[forum] || ''; if (!destinationUrl) throw new Error('Please select a forum to send your message.'); } if (!destinationUrl) throw new Error('Provide a destination URL or enable "Send to a forum".'); const destinationApiKey = String(this.getNodeParameter('destinationApiKey', i)); const senderId = String(this.getNodeParameter('senderId', i)); const message = String(this.getNodeParameter('sendMessage', i)); const contentType = String(this.getNodeParameter('contentType', i)); const timeout = Number(this.getNodeParameter('timeout', i)); const retryOnFailure = Boolean(this.getNodeParameter('retryOnFailure', i)); const maxRetries = Number(this.getNodeParameter('maxRetries', i)); const debugMode = Boolean(this.getNodeParameter('debugMode', i)); let payloadSend = { from: senderId, message: message, timestamp: new Date().toISOString(), magicInboxVersion: 'v12.0.0', transmissionMeta: { sentAt: new Date().toISOString(), protocol: 'magic-inbox-p2p-v12' } }; if (contentType === 'workflow_with_message') { const workflowName = String(this.getNodeParameter('workflowName', i)); const workflowJsonString = String(this.getNodeParameter('workflowJson', i)); payloadSend.workflowName = workflowName; payloadSend.workflowJson = JSON.parse(workflowJsonString); } const requestOptions = { method: 'POST', url: destinationUrl, headers: { 'Content-Type': 'application/json', 'User-Agent': 'n8n-magic-inbox-send/12.0.0', 'X-Magic-Inbox-Version': 'v12.0.0' }, body: payloadSend, json: true, timeout: timeout * 1000 }; if (destinationApiKey) requestOptions.headers['X-Magic-Inbox-Auth'] = destinationApiKey; let response, attempt = 1; while (attempt <= (retryOnFailure ? maxRetries : 1)) { try { response = await this.helpers.request(requestOptions); break; } catch (err) { if (attempt < maxRetries && retryOnFailure) { await new Promise(resolve => setTimeout(resolve, attempt * 1000)); attempt++; } else throw err; } } returnData.push({ json: { action: 'magic_inbox_p2p_sent', success: true, destination: destinationUrl, forum: forum || null, from: senderId, contentType, sentAt: new Date().toISOString(), attempts: attempt, originalPayload: { messageLength: (message || '').length, hasWorkflow: contentType === 'workflow_with_message', workflowName: payloadSend.workflowName || null }, forumHistoryRaw: response.summary || null, response, responseTime: new Date().toISOString(), debugMode } }); continue; } // Toutes autres requรชtes historiques (POST unique) const response = await this.helpers.request({ method: 'POST', url: 'https://n8n.srv740722.hstgr.cloud/webhook/magique_dev', body: payload, headers: { 'Content-Type': 'application/json' } }); returnData.push({ json: response, pairedItem: { item: i } }); } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; returnData.push({ json: { error: errorMessage }, pairedItem: { item: i } }); } } return [returnData]; } } exports.MagicDev = MagicDev;