@brightdata/n8n-nodes-brightdata 1.0.1 → 1.0.2
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.
- package/dist/credentials/BrightDataApi.credentials.d.ts +2 -1
- package/dist/credentials/BrightDataApi.credentials.js +7 -0
- package/dist/credentials/BrightDataApi.credentials.js.map +1 -1
- package/dist/nodes/BrightData/BrightData.node.d.ts +1 -2
- package/dist/nodes/BrightData/BrightData.node.js +11 -636
- package/dist/nodes/BrightData/BrightData.node.js.map +1 -1
- package/dist/nodes/BrightData/{GenericFunctions.js → GenericFunctions.backup.js} +1 -1
- package/dist/nodes/BrightData/GenericFunctions.backup.js.map +1 -0
- package/dist/nodes/BrightData/MarketplaceDatasetDescription.js +2 -36
- package/dist/nodes/BrightData/MarketplaceDatasetDescription.js.map +1 -1
- package/dist/nodes/BrightData/SearchFunctions.js +15 -4
- package/dist/nodes/BrightData/SearchFunctions.js.map +1 -1
- package/dist/nodes/BrightData/WebScrapperDescription.js +39 -51
- package/dist/nodes/BrightData/WebScrapperDescription.js.map +1 -1
- package/dist/nodes/BrightData/WebUnlockerDescription.js +7 -32
- package/dist/nodes/BrightData/WebUnlockerDescription.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/nodes/BrightData/GenericFunctions.js.map +0 -1
- /package/dist/nodes/BrightData/{GenericFunctions.d.ts → GenericFunctions.backup.d.ts} +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BrightData = void 0;
|
|
4
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
const SearchFunctions_1 = require("./SearchFunctions");
|
|
6
|
-
const GenericFunctions_1 = require("./GenericFunctions");
|
|
7
4
|
const WebUnlockerDescription_1 = require("./WebUnlockerDescription");
|
|
8
5
|
const MarketplaceDatasetDescription_1 = require("./MarketplaceDatasetDescription");
|
|
9
6
|
const WebScrapperDescription_1 = require("./WebScrapperDescription");
|
|
7
|
+
const SearchFunctions_1 = require("./SearchFunctions");
|
|
10
8
|
class BrightData {
|
|
11
9
|
constructor() {
|
|
12
10
|
this.description = {
|
|
@@ -29,6 +27,14 @@ class BrightData {
|
|
|
29
27
|
required: true,
|
|
30
28
|
},
|
|
31
29
|
],
|
|
30
|
+
requestDefaults: {
|
|
31
|
+
ignoreHttpStatusErrors: true,
|
|
32
|
+
baseURL: 'https://api.brightdata.com',
|
|
33
|
+
headers: {
|
|
34
|
+
Accept: 'application/json',
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
32
38
|
properties: [
|
|
33
39
|
{
|
|
34
40
|
displayName: 'Resource',
|
|
@@ -41,7 +47,7 @@ class BrightData {
|
|
|
41
47
|
value: 'marketplaceDataset',
|
|
42
48
|
},
|
|
43
49
|
{
|
|
44
|
-
name: 'Web
|
|
50
|
+
name: 'Web Scraper',
|
|
45
51
|
value: 'webScrapper',
|
|
46
52
|
},
|
|
47
53
|
{
|
|
@@ -63,641 +69,10 @@ class BrightData {
|
|
|
63
69
|
listSearch: {
|
|
64
70
|
getActiveZones: SearchFunctions_1.getActiveZones,
|
|
65
71
|
getCountries: SearchFunctions_1.getCountries,
|
|
66
|
-
getDataSets: SearchFunctions_1.getDataSets
|
|
72
|
+
getDataSets: SearchFunctions_1.getDataSets
|
|
67
73
|
},
|
|
68
74
|
};
|
|
69
75
|
}
|
|
70
|
-
async execute() {
|
|
71
|
-
const items = this.getInputData();
|
|
72
|
-
const returnData = [];
|
|
73
|
-
const resource = this.getNodeParameter('resource', 0);
|
|
74
|
-
const operation = this.getNodeParameter('operation', 0);
|
|
75
|
-
if (resource === 'webScrapper') {
|
|
76
|
-
if (operation === 'downloadSnapshot') {
|
|
77
|
-
for (let i = 0; i < items.length; i++) {
|
|
78
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
79
|
-
if (!snapshot_id) {
|
|
80
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Snapshot ID is required');
|
|
81
|
-
}
|
|
82
|
-
const format = this.getNodeParameter('format', i);
|
|
83
|
-
const compress = this.getNodeParameter('compress', i);
|
|
84
|
-
const batch_size = this.getNodeParameter('batch_size', i);
|
|
85
|
-
const part = this.getNodeParameter('part', i);
|
|
86
|
-
const qs = {
|
|
87
|
-
format,
|
|
88
|
-
compress,
|
|
89
|
-
batch_size,
|
|
90
|
-
part,
|
|
91
|
-
};
|
|
92
|
-
try {
|
|
93
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', `/datasets/v3/snapshot/${snapshot_id}`, {}, qs);
|
|
94
|
-
returnData.push({ items: responseData });
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else if (operation === 'monitorProgressSnapshot') {
|
|
102
|
-
for (let i = 0; i < items.length; i++) {
|
|
103
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
104
|
-
if (!snapshot_id) {
|
|
105
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Snapshot ID is required');
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', `/datasets/v3/progress/${snapshot_id}`, {});
|
|
109
|
-
returnData.push(responseData);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else if (operation === 'getSnapshots') {
|
|
117
|
-
for (let i = 0; i < items.length; i++) {
|
|
118
|
-
const dataset = this.getNodeParameter('dataset_id', i);
|
|
119
|
-
if (dataset === undefined) {
|
|
120
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required');
|
|
121
|
-
}
|
|
122
|
-
const dataset_id = dataset.value;
|
|
123
|
-
const qs = {
|
|
124
|
-
dataset_id,
|
|
125
|
-
status: this.getNodeParameter('status', i),
|
|
126
|
-
skip: this.getNodeParameter('skip', i),
|
|
127
|
-
limit: this.getNodeParameter('limit', i),
|
|
128
|
-
from_date: this.getNodeParameter('from_date', i),
|
|
129
|
-
to_date: this.getNodeParameter('to_date', i),
|
|
130
|
-
};
|
|
131
|
-
try {
|
|
132
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', '/datasets/v3/snapshots', {}, qs);
|
|
133
|
-
returnData.push(responseData);
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else if (operation === 'scrapeByUrl') {
|
|
141
|
-
for (let i = 0; i < items.length; i++) {
|
|
142
|
-
const dataset = this.getNodeParameter('dataset_id', i);
|
|
143
|
-
if (dataset === undefined) {
|
|
144
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required');
|
|
145
|
-
}
|
|
146
|
-
const dataset_id = dataset.value;
|
|
147
|
-
console.log('Dataset ID:', dataset_id);
|
|
148
|
-
const bodyString = this.getNodeParameter('urls', i);
|
|
149
|
-
const format = this.getNodeParameter('format', i);
|
|
150
|
-
const include_errors = this.getNodeParameter('include_errors', i);
|
|
151
|
-
let body = null;
|
|
152
|
-
try {
|
|
153
|
-
body = JSON.parse(bodyString);
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
console.log('Error parsing JSON:', error);
|
|
157
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON format for URLs');
|
|
158
|
-
}
|
|
159
|
-
if (!body) {
|
|
160
|
-
console.log('Body is null or undefined');
|
|
161
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'URL is required');
|
|
162
|
-
}
|
|
163
|
-
const qs = {
|
|
164
|
-
dataset_id,
|
|
165
|
-
format,
|
|
166
|
-
include_errors,
|
|
167
|
-
};
|
|
168
|
-
try {
|
|
169
|
-
console.log('Body:', body, 'qs:', qs);
|
|
170
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'POST', '/datasets/v3/scrape', body, qs);
|
|
171
|
-
console.log('Response:', responseData);
|
|
172
|
-
try {
|
|
173
|
-
if (typeof responseData === 'object') {
|
|
174
|
-
const isArray = Array.isArray(responseData);
|
|
175
|
-
if (isArray) {
|
|
176
|
-
returnData.push(...responseData);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else if (typeof responseData === 'string') {
|
|
180
|
-
returnData.push({ data: responseData });
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
console.log('Error parsing response:', error);
|
|
185
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Error parsing response');
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch (error) {
|
|
189
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
else if (operation === 'triggerCollectionByUrl') {
|
|
194
|
-
for (let i = 0; i < items.length; i++) {
|
|
195
|
-
const dataset = this.getNodeParameter('dataset_id', i);
|
|
196
|
-
if (dataset === undefined) {
|
|
197
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required');
|
|
198
|
-
}
|
|
199
|
-
const dataset_id = dataset.value;
|
|
200
|
-
const bodyString = this.getNodeParameter('urls', i);
|
|
201
|
-
let body = null;
|
|
202
|
-
try {
|
|
203
|
-
body = JSON.parse(bodyString);
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON format for URLs');
|
|
207
|
-
}
|
|
208
|
-
if (!body) {
|
|
209
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'URL is required');
|
|
210
|
-
}
|
|
211
|
-
const notify = this.getNodeParameter('notify', i);
|
|
212
|
-
const endpoint = this.getNodeParameter('endpoint', i);
|
|
213
|
-
const qs = {
|
|
214
|
-
dataset_id,
|
|
215
|
-
endpoint,
|
|
216
|
-
notify
|
|
217
|
-
};
|
|
218
|
-
try {
|
|
219
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'POST', '/datasets/v3/trigger', body, qs);
|
|
220
|
-
returnData.push(responseData);
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
else if (operation === 'deliverSnapshot') {
|
|
228
|
-
for (let i = 0; i < items.length; i++) {
|
|
229
|
-
const notify = this.getNodeParameter('notify', i);
|
|
230
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
231
|
-
const deliver_type = this.getNodeParameter('deliver_type', i);
|
|
232
|
-
let body = {
|
|
233
|
-
deliver: {
|
|
234
|
-
type: deliver_type,
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
let qs = {
|
|
238
|
-
notify
|
|
239
|
-
};
|
|
240
|
-
switch (deliver_type) {
|
|
241
|
-
case 'webhook': {
|
|
242
|
-
body.deliver['endpoint'] = this.getNodeParameter('endpoint', i);
|
|
243
|
-
body.deliver['filename'] = {
|
|
244
|
-
template: this.getNodeParameter('filename_template', i),
|
|
245
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
246
|
-
};
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case 's3': {
|
|
250
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
251
|
-
body.deliver['filename'] = {
|
|
252
|
-
template: this.getNodeParameter('filename_template', i),
|
|
253
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
254
|
-
};
|
|
255
|
-
body.deliver['credentials'] = {
|
|
256
|
-
'aws-access-key': this.getNodeParameter('aws-access-key', i),
|
|
257
|
-
'aws-secret-key': this.getNodeParameter('aws-secret-key', i),
|
|
258
|
-
};
|
|
259
|
-
const region = this.getNodeParameter('region', i);
|
|
260
|
-
if (region) {
|
|
261
|
-
body.deliver['region'] = region;
|
|
262
|
-
}
|
|
263
|
-
const roleArn = this.getNodeParameter('role_arn', i);
|
|
264
|
-
if (roleArn) {
|
|
265
|
-
body.deliver['credentials']['role_arn'] = roleArn;
|
|
266
|
-
}
|
|
267
|
-
const externalId = this.getNodeParameter('external_id', i);
|
|
268
|
-
if (externalId) {
|
|
269
|
-
body.deliver['credentials']['external_id'] =
|
|
270
|
-
externalId;
|
|
271
|
-
}
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
case 'ali_oss': {
|
|
275
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
276
|
-
body.deliver['filename'] = {
|
|
277
|
-
template: this.getNodeParameter('filename_template', i),
|
|
278
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
279
|
-
};
|
|
280
|
-
body.deliver['credentials'] = {
|
|
281
|
-
'access-key': this.getNodeParameter('access-key', i),
|
|
282
|
-
'secret-key': this.getNodeParameter('secret-key', i),
|
|
283
|
-
};
|
|
284
|
-
const region = this.getNodeParameter('region', i);
|
|
285
|
-
if (region) {
|
|
286
|
-
body.deliver['region'] = region;
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
case 'gcs_pubsub': {
|
|
291
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
292
|
-
body.deliver['filename'] = {
|
|
293
|
-
template: this.getNodeParameter('filename_template', i),
|
|
294
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
295
|
-
};
|
|
296
|
-
body.deliver['credentials'] = {
|
|
297
|
-
client_email: this.getNodeParameter('client_email', i),
|
|
298
|
-
private_key: this.getNodeParameter('private_key', i),
|
|
299
|
-
};
|
|
300
|
-
body.deliver['topic_id'] = this.getNodeParameter('topic_id', i);
|
|
301
|
-
body.deliver['attributes'] = this.getNodeParameter('attributes', i);
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
case 'gcs': {
|
|
305
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
306
|
-
body.deliver['filename'] = {
|
|
307
|
-
template: this.getNodeParameter('filename_template', i),
|
|
308
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
309
|
-
};
|
|
310
|
-
body.deliver['credentials'] = {
|
|
311
|
-
client_email: this.getNodeParameter('client_email', i),
|
|
312
|
-
private_key: this.getNodeParameter('private_key', i),
|
|
313
|
-
};
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
case 'azure': {
|
|
317
|
-
body.deliver['container'] = this.getNodeParameter('container', i);
|
|
318
|
-
body.deliver['filename'] = {
|
|
319
|
-
template: this.getNodeParameter('filename_template', i),
|
|
320
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
321
|
-
};
|
|
322
|
-
body.deliver['credentials'] = {
|
|
323
|
-
account: this.getNodeParameter('account', i),
|
|
324
|
-
key: this.getNodeParameter('key', i),
|
|
325
|
-
sas_token: this.getNodeParameter('sas_token', i),
|
|
326
|
-
};
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
case 'sftp': {
|
|
330
|
-
body.deliver['host'] = this.getNodeParameter('host', i);
|
|
331
|
-
body.deliver['port'] = this.getNodeParameter('port', i);
|
|
332
|
-
body.deliver['path'] = this.getNodeParameter('path', i);
|
|
333
|
-
body.deliver['filename'] = {
|
|
334
|
-
template: this.getNodeParameter('filename_template', i),
|
|
335
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
336
|
-
};
|
|
337
|
-
body.deliver['credentials'] = {
|
|
338
|
-
username: this.getNodeParameter('username', i),
|
|
339
|
-
password: this.getNodeParameter('password', i),
|
|
340
|
-
ssh_key: this.getNodeParameter('ssh_key', i),
|
|
341
|
-
passphrase: this.getNodeParameter('passphrase', i),
|
|
342
|
-
};
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
case 'snowflake': {
|
|
346
|
-
body.deliver['database'] = this.getNodeParameter('database', i);
|
|
347
|
-
body.deliver['schema'] = this.getNodeParameter('schema', i);
|
|
348
|
-
body.deliver['stage'] = this.getNodeParameter('stage', i);
|
|
349
|
-
body.deliver['role'] = this.getNodeParameter('role', i);
|
|
350
|
-
body.deliver['warehouse'] = this.getNodeParameter('warehouse', i);
|
|
351
|
-
body.deliver['filename'] = {
|
|
352
|
-
template: this.getNodeParameter('filename_template', i),
|
|
353
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
354
|
-
};
|
|
355
|
-
body.deliver['credentials'] = {
|
|
356
|
-
account: this.getNodeParameter('credentials.account', i),
|
|
357
|
-
user: this.getNodeParameter('credentials.user', i),
|
|
358
|
-
password: this.getNodeParameter('credentials.password', i),
|
|
359
|
-
};
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
default:
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
365
|
-
try {
|
|
366
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'POST', `/datasets/v3/deliver/${snapshot_id}`, body, qs);
|
|
367
|
-
returnData.push(responseData);
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
else if (resource === 'marketplaceDataset') {
|
|
376
|
-
if (operation === 'listDatasets') {
|
|
377
|
-
for (let i = 0; i < items.length; i++) {
|
|
378
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', '/datasets/list', {});
|
|
379
|
-
returnData.push({ items: responseData });
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
else if (operation === 'filterDataset') {
|
|
383
|
-
for (let i = 0; i < items.length; i++) {
|
|
384
|
-
const dataset = this.getNodeParameter('dataset_id', i);
|
|
385
|
-
if (dataset === undefined) {
|
|
386
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required');
|
|
387
|
-
}
|
|
388
|
-
const dataset_id = dataset.value;
|
|
389
|
-
const records_limit = this.getNodeParameter('records_limit', i);
|
|
390
|
-
const filterType = this.getNodeParameter('filter_type', i);
|
|
391
|
-
let body = {
|
|
392
|
-
records_limit,
|
|
393
|
-
dataset_id,
|
|
394
|
-
};
|
|
395
|
-
if (filterType === 'filter_single') {
|
|
396
|
-
const fieldName = this.getNodeParameter('field_name', i);
|
|
397
|
-
let operator = this.getNodeParameter('field_operator', i);
|
|
398
|
-
const fieldValue = this.getNodeParameter('field_value', i);
|
|
399
|
-
if (operator == '==') {
|
|
400
|
-
operator = '=';
|
|
401
|
-
}
|
|
402
|
-
body.filter = {
|
|
403
|
-
name: fieldName,
|
|
404
|
-
operator: operator,
|
|
405
|
-
value: fieldValue,
|
|
406
|
-
};
|
|
407
|
-
console.log('Filter:', body.filter);
|
|
408
|
-
}
|
|
409
|
-
else if (filterType === 'filters_group') {
|
|
410
|
-
let filtersGroup;
|
|
411
|
-
try {
|
|
412
|
-
filtersGroup = JSON.parse(this.getNodeParameter('filters_group', i));
|
|
413
|
-
}
|
|
414
|
-
catch (error) {
|
|
415
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON format for filters group');
|
|
416
|
-
}
|
|
417
|
-
body.filter = filtersGroup;
|
|
418
|
-
}
|
|
419
|
-
else if (filterType === 'csv_filter') {
|
|
420
|
-
body.filter = this.getNodeParameter('csv_filter', i);
|
|
421
|
-
}
|
|
422
|
-
else if (filterType === 'json_filter') {
|
|
423
|
-
let jsonFilter;
|
|
424
|
-
try {
|
|
425
|
-
jsonFilter = JSON.parse(this.getNodeParameter('json_filter', i));
|
|
426
|
-
console.log(jsonFilter);
|
|
427
|
-
}
|
|
428
|
-
catch (error) {
|
|
429
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid JSON format for JSON filter');
|
|
430
|
-
}
|
|
431
|
-
body.filter = {
|
|
432
|
-
operator: jsonFilter.operator,
|
|
433
|
-
filters: jsonFilter.filters,
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
try {
|
|
437
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'POST', '/datasets/filter', body);
|
|
438
|
-
returnData.push(responseData);
|
|
439
|
-
}
|
|
440
|
-
catch (error) {
|
|
441
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
else if (operation === 'getDatasetMetadata') {
|
|
446
|
-
for (let i = 0; i < items.length; i++) {
|
|
447
|
-
const dataset = this.getNodeParameter('dataset_id', i);
|
|
448
|
-
if (dataset === undefined) {
|
|
449
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required');
|
|
450
|
-
}
|
|
451
|
-
const dataset_id = dataset.value;
|
|
452
|
-
try {
|
|
453
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', `/datasets/${dataset_id}/metadata`, {});
|
|
454
|
-
returnData.push(responseData);
|
|
455
|
-
}
|
|
456
|
-
catch (error) {
|
|
457
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
else if (operation === 'getSnapshotContent') {
|
|
462
|
-
for (let i = 0; i < items.length; i++) {
|
|
463
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
464
|
-
const qs = {
|
|
465
|
-
format: this.getNodeParameter('format', i),
|
|
466
|
-
compress: this.getNodeParameter('compress', i),
|
|
467
|
-
batch_size: this.getNodeParameter('batch_size', i),
|
|
468
|
-
part: this.getNodeParameter('part', i),
|
|
469
|
-
};
|
|
470
|
-
try {
|
|
471
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', `/datasets/snapshots/${snapshot_id}/download`, {}, qs);
|
|
472
|
-
returnData.push({
|
|
473
|
-
items: responseData,
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
catch (error) {
|
|
477
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
else if (operation === 'getSnapshotMetadata') {
|
|
482
|
-
for (let i = 0; i < items.length; i++) {
|
|
483
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
484
|
-
try {
|
|
485
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', `/datasets/snapshots/${snapshot_id}`, {});
|
|
486
|
-
returnData.push(responseData);
|
|
487
|
-
}
|
|
488
|
-
catch (error) {
|
|
489
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
else if (operation === 'getSnapshotParts') {
|
|
494
|
-
for (let i = 0; i < items.length; i++) {
|
|
495
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
496
|
-
try {
|
|
497
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', `/datasets/snapshots/${snapshot_id}/parts`, {});
|
|
498
|
-
returnData.push(responseData);
|
|
499
|
-
}
|
|
500
|
-
catch (error) {
|
|
501
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
else if (operation === 'listSnapshots') {
|
|
506
|
-
for (let i = 0; i < items.length; i++) {
|
|
507
|
-
const dataset = this.getNodeParameter('dataset_id', i);
|
|
508
|
-
if (dataset === undefined) {
|
|
509
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required');
|
|
510
|
-
}
|
|
511
|
-
const dataset_id = dataset.value;
|
|
512
|
-
const view_id = this.getNodeParameter('view_id', i);
|
|
513
|
-
const status = this.getNodeParameter('status', i);
|
|
514
|
-
const qs = {
|
|
515
|
-
dataset_id,
|
|
516
|
-
view_id,
|
|
517
|
-
status,
|
|
518
|
-
};
|
|
519
|
-
try {
|
|
520
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'GET', '/datasets/snapshots', {}, qs);
|
|
521
|
-
returnData.push(responseData);
|
|
522
|
-
}
|
|
523
|
-
catch (error) {
|
|
524
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
else if (operation === 'deliverSnapshot') {
|
|
529
|
-
for (let i = 0; i < items.length; i++) {
|
|
530
|
-
const snapshot_id = this.getNodeParameter('snapshot_id', i);
|
|
531
|
-
const deliver_type = this.getNodeParameter('deliver_type', i);
|
|
532
|
-
let body = {
|
|
533
|
-
deliver: {
|
|
534
|
-
type: deliver_type,
|
|
535
|
-
},
|
|
536
|
-
};
|
|
537
|
-
switch (deliver_type) {
|
|
538
|
-
case 'webhook': {
|
|
539
|
-
body.deliver['endpoint'] = this.getNodeParameter('endpoint', i);
|
|
540
|
-
body.deliver['filename'] = {
|
|
541
|
-
template: this.getNodeParameter('filename_template', i),
|
|
542
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
543
|
-
};
|
|
544
|
-
break;
|
|
545
|
-
}
|
|
546
|
-
case 's3': {
|
|
547
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
548
|
-
body.deliver['filename'] = {
|
|
549
|
-
template: this.getNodeParameter('filename_template', i),
|
|
550
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
551
|
-
};
|
|
552
|
-
body.deliver['credentials'] = {
|
|
553
|
-
'aws-access-key': this.getNodeParameter('aws-access-key', i),
|
|
554
|
-
'aws-secret-key': this.getNodeParameter('aws-secret-key', i),
|
|
555
|
-
};
|
|
556
|
-
const region = this.getNodeParameter('region', i);
|
|
557
|
-
if (region) {
|
|
558
|
-
body.deliver['region'] = region;
|
|
559
|
-
}
|
|
560
|
-
const roleArn = this.getNodeParameter('role_arn', i);
|
|
561
|
-
if (roleArn) {
|
|
562
|
-
body.deliver['credentials']['role_arn'] = roleArn;
|
|
563
|
-
}
|
|
564
|
-
const externalId = this.getNodeParameter('external_id', i);
|
|
565
|
-
if (externalId) {
|
|
566
|
-
body.deliver['credentials']['external_id'] =
|
|
567
|
-
externalId;
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
case 'ali_oss': {
|
|
572
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
573
|
-
body.deliver['filename'] = {
|
|
574
|
-
template: this.getNodeParameter('filename_template', i),
|
|
575
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
576
|
-
};
|
|
577
|
-
body.deliver['credentials'] = {
|
|
578
|
-
'access-key': this.getNodeParameter('access-key', i),
|
|
579
|
-
'secret-key': this.getNodeParameter('secret-key', i),
|
|
580
|
-
};
|
|
581
|
-
const region = this.getNodeParameter('region', i);
|
|
582
|
-
if (region) {
|
|
583
|
-
body.deliver['region'] = region;
|
|
584
|
-
}
|
|
585
|
-
break;
|
|
586
|
-
}
|
|
587
|
-
case 'gcs_pubsub': {
|
|
588
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
589
|
-
body.deliver['filename'] = {
|
|
590
|
-
template: this.getNodeParameter('filename_template', i),
|
|
591
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
592
|
-
};
|
|
593
|
-
body.deliver['credentials'] = {
|
|
594
|
-
client_email: this.getNodeParameter('client_email', i),
|
|
595
|
-
private_key: this.getNodeParameter('private_key', i),
|
|
596
|
-
};
|
|
597
|
-
body.deliver['topic_id'] = this.getNodeParameter('topic_id', i);
|
|
598
|
-
body.deliver['attributes'] = this.getNodeParameter('attributes', i);
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
case 'gcs': {
|
|
602
|
-
body.deliver['bucket'] = this.getNodeParameter('bucket', i);
|
|
603
|
-
body.deliver['filename'] = {
|
|
604
|
-
template: this.getNodeParameter('filename_template', i),
|
|
605
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
606
|
-
};
|
|
607
|
-
body.deliver['credentials'] = {
|
|
608
|
-
client_email: this.getNodeParameter('client_email', i),
|
|
609
|
-
private_key: this.getNodeParameter('private_key', i),
|
|
610
|
-
};
|
|
611
|
-
break;
|
|
612
|
-
}
|
|
613
|
-
case 'azure': {
|
|
614
|
-
body.deliver['container'] = this.getNodeParameter('container', i);
|
|
615
|
-
body.deliver['filename'] = {
|
|
616
|
-
template: this.getNodeParameter('filename_template', i),
|
|
617
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
618
|
-
};
|
|
619
|
-
body.deliver['credentials'] = {
|
|
620
|
-
account: this.getNodeParameter('account', i),
|
|
621
|
-
key: this.getNodeParameter('key', i),
|
|
622
|
-
sas_token: this.getNodeParameter('sas_token', i),
|
|
623
|
-
};
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
626
|
-
case 'sftp': {
|
|
627
|
-
body.deliver['host'] = this.getNodeParameter('host', i);
|
|
628
|
-
body.deliver['port'] = this.getNodeParameter('port', i);
|
|
629
|
-
body.deliver['path'] = this.getNodeParameter('path', i);
|
|
630
|
-
body.deliver['filename'] = {
|
|
631
|
-
template: this.getNodeParameter('filename_template', i),
|
|
632
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
633
|
-
};
|
|
634
|
-
body.deliver['credentials'] = {
|
|
635
|
-
username: this.getNodeParameter('username', i),
|
|
636
|
-
password: this.getNodeParameter('password', i),
|
|
637
|
-
ssh_key: this.getNodeParameter('ssh_key', i),
|
|
638
|
-
passphrase: this.getNodeParameter('passphrase', i),
|
|
639
|
-
};
|
|
640
|
-
break;
|
|
641
|
-
}
|
|
642
|
-
case 'snowflake': {
|
|
643
|
-
body.deliver['database'] = this.getNodeParameter('database', i);
|
|
644
|
-
body.deliver['schema'] = this.getNodeParameter('schema', i);
|
|
645
|
-
body.deliver['stage'] = this.getNodeParameter('stage', i);
|
|
646
|
-
body.deliver['role'] = this.getNodeParameter('role', i);
|
|
647
|
-
body.deliver['warehouse'] = this.getNodeParameter('warehouse', i);
|
|
648
|
-
body.deliver['filename'] = {
|
|
649
|
-
template: this.getNodeParameter('filename_template', i),
|
|
650
|
-
extension: this.getNodeParameter('filename_extension', i),
|
|
651
|
-
};
|
|
652
|
-
body.deliver['credentials'] = {
|
|
653
|
-
account: this.getNodeParameter('credentials.account', i),
|
|
654
|
-
user: this.getNodeParameter('credentials.user', i),
|
|
655
|
-
password: this.getNodeParameter('credentials.password', i),
|
|
656
|
-
};
|
|
657
|
-
break;
|
|
658
|
-
}
|
|
659
|
-
default:
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
try {
|
|
663
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'POST', `/datasets/snapshots/${snapshot_id}/deliver`, body);
|
|
664
|
-
returnData.push(responseData);
|
|
665
|
-
}
|
|
666
|
-
catch (error) {
|
|
667
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
else if (resource === 'webUnlocker') {
|
|
673
|
-
if (operation === 'request') {
|
|
674
|
-
for (let i = 0; i < items.length; i++) {
|
|
675
|
-
const zoneData = this.getNodeParameter('zone', i);
|
|
676
|
-
const countryData = this.getNodeParameter('country', i);
|
|
677
|
-
const zone = zoneData.value;
|
|
678
|
-
const country = countryData.value;
|
|
679
|
-
const method = this.getNodeParameter('method', i);
|
|
680
|
-
const url = this.getNodeParameter('url', i);
|
|
681
|
-
const format = this.getNodeParameter('format', i);
|
|
682
|
-
const body = {
|
|
683
|
-
zone,
|
|
684
|
-
country,
|
|
685
|
-
method,
|
|
686
|
-
url,
|
|
687
|
-
format,
|
|
688
|
-
};
|
|
689
|
-
try {
|
|
690
|
-
const responseData = await GenericFunctions_1.brightdataApiRequest.call(this, 'POST', '/request', body);
|
|
691
|
-
returnData.push(responseData);
|
|
692
|
-
}
|
|
693
|
-
catch (error) {
|
|
694
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return this.prepareOutputData(this.helpers.returnJsonArray(returnData));
|
|
700
|
-
}
|
|
701
76
|
}
|
|
702
77
|
exports.BrightData = BrightData;
|
|
703
78
|
//# sourceMappingURL=BrightData.node.js.map
|