n8n-nodes-firecrawl-latest 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/LICENSE.md +19 -0
  2. package/README.md +232 -0
  3. package/dist/credentials/FirecrawlApi.credentials.js +22 -0
  4. package/dist/icons/flames-icon.svg +144 -0
  5. package/dist/nodes/Firecrawl/FireCrawlScraper.node.js +156 -0
  6. package/dist/nodes/Firecrawl/resources/batchScrape/batchScrape.methods.js +253 -0
  7. package/dist/nodes/Firecrawl/resources/batchScrape/batchScrape.properties.js +205 -0
  8. package/dist/nodes/Firecrawl/resources/crawler/crawler.methods.js +281 -0
  9. package/dist/nodes/Firecrawl/resources/crawler/crawler.properties.js +313 -0
  10. package/dist/nodes/Firecrawl/resources/deepResearch/deepResearch.methods.js +171 -0
  11. package/dist/nodes/Firecrawl/resources/deepResearch/deepResearch.properties.js +200 -0
  12. package/dist/nodes/Firecrawl/resources/extract/extract.methods.js +424 -0
  13. package/dist/nodes/Firecrawl/resources/extract/extract.properties.js +339 -0
  14. package/dist/nodes/Firecrawl/resources/llmsText/llmsText.methods.js +124 -0
  15. package/dist/nodes/Firecrawl/resources/llmsText/llmsText.properties.js +87 -0
  16. package/dist/nodes/Firecrawl/resources/map/map.methods.js +52 -0
  17. package/dist/nodes/Firecrawl/resources/map/map.properties.js +22 -0
  18. package/dist/nodes/Firecrawl/resources/scrape/scrape.methods.js +203 -0
  19. package/dist/nodes/Firecrawl/resources/scrape/scrape.properties.js +348 -0
  20. package/dist/nodes/HttpBin/HttpBin.node.js +59 -0
  21. package/dist/nodes/HttpBin/HttpVerbDescription.js +246 -0
  22. package/dist/nodes/HttpBin/httpbin.svg +18 -0
  23. package/index.js +7 -0
  24. package/package.json +58 -0
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deepResearchMethods = void 0;
7
+ const firecrawl_js_1 = __importDefault(require("@mendable/firecrawl-js"));
8
+ const n8n_workflow_1 = require("n8n-workflow");
9
+ exports.deepResearchMethods = {
10
+ async execute() {
11
+ const items = this.getInputData();
12
+ const returnData = [];
13
+ // Get credentials
14
+ const credentials = await this.getCredentials('firecrawlApi');
15
+ const apiKey = credentials.apiKey;
16
+ // Initialize Firecrawl app
17
+ const firecrawl = new firecrawl_js_1.default({ apiKey });
18
+ // Process each item
19
+ for (let i = 0; i < items.length; i++) {
20
+ try {
21
+ // Get operation mode
22
+ const operationMode = this.getNodeParameter('operationMode', i);
23
+ if (operationMode === 'new') {
24
+ // Start a new research task
25
+ const query = this.getNodeParameter('query', i);
26
+ const maxDepth = this.getNodeParameter('maxDepth', i, 7);
27
+ const timeLimit = this.getNodeParameter('timeLimit', i, 270);
28
+ const maxUrls = this.getNodeParameter('maxUrls', i, 20);
29
+ const systemPrompt = this.getNodeParameter('systemPrompt', i, '');
30
+ const analysisPrompt = this.getNodeParameter('analysisPrompt', i, '');
31
+ const jsonOutput = this.getNodeParameter('jsonOutput', i, false);
32
+ const waitForCompletion = this.getNodeParameter('waitForCompletion', i, true);
33
+ const trackActivity = this.getNodeParameter('trackActivity', i, false);
34
+ // Prepare research parameters
35
+ const params = {
36
+ maxDepth,
37
+ timeLimit,
38
+ maxUrls,
39
+ };
40
+ // Add optional parameters if provided
41
+ if (systemPrompt)
42
+ params.systemPrompt = systemPrompt;
43
+ if (analysisPrompt)
44
+ params.analysisPrompt = analysisPrompt;
45
+ // Add JSON output settings if enabled
46
+ if (jsonOutput) {
47
+ params.formats = ['json'];
48
+ const jsonSchema = this.getNodeParameter('jsonSchema', i, '{}');
49
+ params.jsonOptions = {
50
+ schema: JSON.parse(jsonSchema),
51
+ };
52
+ }
53
+ // Handle different operation modes
54
+ if (waitForCompletion) {
55
+ // Start research with optional activity tracking
56
+ let results;
57
+ if (trackActivity) {
58
+ // Initialize an array to store activities
59
+ const activities = [];
60
+ // Define activity callback
61
+ const onActivity = (activity) => {
62
+ activities.push(activity);
63
+ };
64
+ // Run research with activity tracking
65
+ results = await firecrawl.deepResearch(query, params, onActivity);
66
+ // Add activities to results if not an error
67
+ if (results.success && !('error' in results)) {
68
+ results.activities = activities;
69
+ }
70
+ }
71
+ else {
72
+ // Run research without activity tracking
73
+ results = await firecrawl.deepResearch(query, params);
74
+ }
75
+ if (!results.success && 'error' in results) {
76
+ returnData.push({
77
+ json: {
78
+ success: false,
79
+ status: 'error',
80
+ error: results.error,
81
+ },
82
+ });
83
+ }
84
+ else {
85
+ const resultData = results;
86
+ returnData.push({
87
+ json: {
88
+ success: true,
89
+ status: resultData.status || 'completed',
90
+ data: resultData.data,
91
+ currentDepth: resultData.currentDepth,
92
+ maxDepth: resultData.maxDepth,
93
+ expiresAt: resultData.expiresAt,
94
+ activities: resultData.activities,
95
+ },
96
+ });
97
+ }
98
+ }
99
+ else {
100
+ // Start a new research job asynchronously
101
+ const job = await firecrawl.asyncDeepResearch(query, params);
102
+ if (!job.success && 'error' in job) {
103
+ returnData.push({
104
+ json: {
105
+ success: false,
106
+ status: 'error',
107
+ error: job.error,
108
+ },
109
+ });
110
+ }
111
+ else {
112
+ returnData.push({
113
+ json: {
114
+ success: true,
115
+ status: 'started',
116
+ jobId: 'jobId' in job ? job.jobId : undefined,
117
+ message: 'Deep research started successfully. Use the job ID to check status.',
118
+ },
119
+ });
120
+ }
121
+ }
122
+ }
123
+ else {
124
+ // Check the status of an existing job
125
+ const jobId = this.getNodeParameter('jobId', i);
126
+ const status = await firecrawl.checkDeepResearchStatus(jobId);
127
+ if (!status.success && 'error' in status) {
128
+ returnData.push({
129
+ json: {
130
+ success: false,
131
+ status: 'error',
132
+ error: status.error,
133
+ jobId,
134
+ },
135
+ });
136
+ }
137
+ else {
138
+ returnData.push({
139
+ json: {
140
+ success: true,
141
+ status: 'status' in status ? status.status : 'unknown',
142
+ jobId,
143
+ currentDepth: 'currentDepth' in status ? status.currentDepth : undefined,
144
+ maxDepth: 'maxDepth' in status ? status.maxDepth : undefined,
145
+ data: 'data' in status ? status.data : undefined,
146
+ expiresAt: 'expiresAt' in status ? status.expiresAt : undefined,
147
+ },
148
+ });
149
+ }
150
+ }
151
+ }
152
+ catch (error) {
153
+ const errorMessage = error instanceof Error ? error.message : String(error);
154
+ console.error('Deep Research error:', errorMessage);
155
+ if (this.continueOnFail()) {
156
+ returnData.push({
157
+ json: {
158
+ success: false,
159
+ error: errorMessage,
160
+ },
161
+ });
162
+ continue;
163
+ }
164
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
165
+ itemIndex: i,
166
+ });
167
+ }
168
+ }
169
+ return [returnData];
170
+ },
171
+ };
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepResearchProperties = void 0;
4
+ // Fields for the Deep Research resource
5
+ const deepResearchFields = [
6
+ {
7
+ displayName: 'Query',
8
+ name: 'query',
9
+ type: 'string',
10
+ displayOptions: {
11
+ show: {
12
+ resource: ['deepResearch'],
13
+ },
14
+ },
15
+ default: '',
16
+ required: true,
17
+ description: 'The research topic or question you want to investigate',
18
+ placeholder: 'What are the latest developments in quantum computing?',
19
+ },
20
+ {
21
+ displayName: 'Operation Mode',
22
+ name: 'operationMode',
23
+ type: 'options',
24
+ displayOptions: {
25
+ show: {
26
+ resource: ['deepResearch'],
27
+ },
28
+ },
29
+ options: [
30
+ {
31
+ name: 'Start New Research',
32
+ value: 'new',
33
+ description: 'Start a new deep research task',
34
+ },
35
+ {
36
+ name: 'Check Status',
37
+ value: 'status',
38
+ description: 'Check the status of an existing research task',
39
+ },
40
+ ],
41
+ default: 'new',
42
+ description: 'Whether to start a new research task or check an existing one',
43
+ },
44
+ {
45
+ displayName: 'Job ID',
46
+ name: 'jobId',
47
+ type: 'string',
48
+ displayOptions: {
49
+ show: {
50
+ resource: ['deepResearch'],
51
+ operationMode: ['status'],
52
+ },
53
+ },
54
+ default: '',
55
+ required: true,
56
+ description: 'The ID of the research job to check',
57
+ },
58
+ {
59
+ displayName: 'Maximum Depth',
60
+ name: 'maxDepth',
61
+ type: 'number',
62
+ typeOptions: {
63
+ minValue: 1,
64
+ maxValue: 10,
65
+ },
66
+ displayOptions: {
67
+ show: {
68
+ resource: ['deepResearch'],
69
+ operationMode: ['new'],
70
+ },
71
+ },
72
+ default: 7,
73
+ description: 'Maximum number of research iterations (1-10)',
74
+ },
75
+ {
76
+ displayName: 'Time Limit (Seconds)',
77
+ name: 'timeLimit',
78
+ type: 'number',
79
+ typeOptions: {
80
+ minValue: 30,
81
+ maxValue: 300,
82
+ },
83
+ displayOptions: {
84
+ show: {
85
+ resource: ['deepResearch'],
86
+ operationMode: ['new'],
87
+ },
88
+ },
89
+ default: 270,
90
+ description: 'Time limit in seconds (30-300)',
91
+ },
92
+ {
93
+ displayName: 'Maximum URLs',
94
+ name: 'maxUrls',
95
+ type: 'number',
96
+ typeOptions: {
97
+ minValue: 1,
98
+ maxValue: 1000,
99
+ },
100
+ displayOptions: {
101
+ show: {
102
+ resource: ['deepResearch'],
103
+ operationMode: ['new'],
104
+ },
105
+ },
106
+ default: 20,
107
+ description: 'Maximum number of URLs to analyze (1-1000)',
108
+ },
109
+ {
110
+ displayName: 'System Prompt',
111
+ name: 'systemPrompt',
112
+ type: 'string',
113
+ typeOptions: {
114
+ rows: 4,
115
+ },
116
+ displayOptions: {
117
+ show: {
118
+ resource: ['deepResearch'],
119
+ operationMode: ['new'],
120
+ },
121
+ },
122
+ default: '',
123
+ description: 'Optional system prompt to guide the research process',
124
+ },
125
+ {
126
+ displayName: 'Analysis Prompt',
127
+ name: 'analysisPrompt',
128
+ type: 'string',
129
+ typeOptions: {
130
+ rows: 4,
131
+ },
132
+ displayOptions: {
133
+ show: {
134
+ resource: ['deepResearch'],
135
+ operationMode: ['new'],
136
+ },
137
+ },
138
+ default: '',
139
+ description: 'Optional prompt for customizing the final analysis',
140
+ },
141
+ {
142
+ displayName: 'JSON Output',
143
+ name: 'jsonOutput',
144
+ type: 'boolean',
145
+ displayOptions: {
146
+ show: {
147
+ resource: ['deepResearch'],
148
+ operationMode: ['new'],
149
+ },
150
+ },
151
+ default: false,
152
+ description: 'Whether to output the research results in structured JSON format',
153
+ },
154
+ {
155
+ displayName: 'JSON Schema',
156
+ name: 'jsonSchema',
157
+ type: 'json',
158
+ typeOptions: {
159
+ alwaysOpenEditWindow: true,
160
+ rows: 10,
161
+ },
162
+ displayOptions: {
163
+ show: {
164
+ resource: ['deepResearch'],
165
+ operationMode: ['new'],
166
+ jsonOutput: [true],
167
+ },
168
+ },
169
+ default: '{\n "type": "object",\n "properties": {\n "keyFindings": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "relevantCompanies": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "name": {\n "type": "string"\n },\n "relevance": {\n "type": "string"\n }\n }\n }\n }\n }\n}',
170
+ description: 'Schema for structured JSON output (if JSON Output is enabled)',
171
+ },
172
+ {
173
+ displayName: 'Real-Time Updates',
174
+ name: 'trackActivity',
175
+ type: 'boolean',
176
+ displayOptions: {
177
+ show: {
178
+ resource: ['deepResearch'],
179
+ operationMode: ['new'],
180
+ },
181
+ },
182
+ default: false,
183
+ description: 'Whether to track research activities in real-time (not recommended for n8n)',
184
+ },
185
+ {
186
+ displayName: 'Wait for Completion',
187
+ name: 'waitForCompletion',
188
+ type: 'boolean',
189
+ displayOptions: {
190
+ show: {
191
+ resource: ['deepResearch'],
192
+ operationMode: ['new'],
193
+ },
194
+ },
195
+ default: true,
196
+ description: 'Whether to wait for the research to complete before returning',
197
+ },
198
+ ];
199
+ // Export all properties for the Deep Research resource
200
+ exports.deepResearchProperties = [...deepResearchFields];