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
JavaScript
"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;