豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 56cbaf8

Browse files
update generator
1 parent 5afa91c commit 56cbaf8

23 files changed

+35467
-34699
lines changed

credentials/HasDataApi.credentials.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {
33
ICredentialTestRequest,
44
ICredentialType,
55
INodeProperties,
6+
Icon,
67
} from 'n8n-workflow';
78

89
export class HasDataApi implements ICredentialType {
910
name = 'hasDataApi';
11+
icon: Icon = 'file:hasdata.svg';
1012
displayName = 'HasData API';
1113
documentationUrl = 'https://docs.hasdata.com';
1214
properties: INodeProperties[] = [

credentials/hasdata.svg

Lines changed: 7 additions & 0 deletions
Loading

nodes/HasData/HasData.node.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
1+
/* eslint-disable n8n-nodes-base/node-param-options-type-unsorted-items */
22
import {
33
IDataObject,
44
IExecuteFunctions,
55
IHttpRequestMethods,
66
INodeExecutionData,
7+
INodeProperties,
78
INodeType,
89
INodeTypeDescription,
910
} from 'n8n-workflow';
@@ -168,7 +169,7 @@ export class HasData implements INodeType {
168169

169170
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
170171
const items = this.getInputData();
171-
const returnData: IDataObject[] = [];
172+
const returnData: INodeExecutionData[] = [];
172173
const resource = this.getNodeParameter('resource', 0) as string;
173174
const operation = this.getNodeParameter('operation', 0) as string;
174175

@@ -182,7 +183,11 @@ export class HasData implements INodeType {
182183
// Endpoint Logic
183184
const opKebab = operation.replace(/_/g, '-');
184185
if (resource === 'google_serp' || resource === 'google_images') {
185-
endpoint = `/scrape/google/${opKebab}`;
186+
if (operation === 'serp_light') {
187+
endpoint = '/scrape/google-light/serp';
188+
} else {
189+
endpoint = `/scrape/google/${opKebab}`;
190+
}
186191
} else if (resource === 'google_travel') {
187192
endpoint = `/scrape/google/${opKebab}`;
188193
} else if (resource === 'google_maps') {
@@ -199,7 +204,7 @@ export class HasData implements INodeType {
199204

200205
// Parameter Handling
201206
// We need to fetch parameters dynamically based on the resource fields
202-
let relevantFields: any[] = [];
207+
let relevantFields: INodeProperties[] = [];
203208
if (resource === 'airbnb') relevantFields = airbnbFields;
204209
else if (resource === 'amazon') relevantFields = amazonFields;
205210
else if (resource === 'bing') relevantFields = bingFields;
@@ -230,7 +235,7 @@ export class HasData implements INodeType {
230235
const originalName = fieldName.replace(/__opt__/g, '[').replace(/__clt__/g, ']');
231236
qs[originalName] = value;
232237
}
233-
} catch (e) {
238+
} catch {
234239
// Param not displayed/found
235240
}
236241
}
@@ -244,7 +249,7 @@ export class HasData implements INodeType {
244249
qs[originalKey] = additionalFields[key];
245250
}
246251
}
247-
} catch (e) {
252+
} catch {
248253
// additionalFields not found
249254
}
250255

@@ -261,17 +266,21 @@ export class HasData implements INodeType {
261266
}
262267
}
263268

264-
const response = await this.helpers.requestWithAuthentication.call(this, 'hasDataApi', {
265-
method,
266-
baseURL: 'https://api.hasdata.com',
267-
url: endpoint,
268-
qs,
269-
body: method === 'POST' ? body : undefined,
270-
json: true,
271-
});
269+
const responseData = await this.helpers.httpRequestWithAuthentication.call(
270+
this,
271+
'hasDataApi',
272+
{
273+
method,
274+
baseURL: 'https://api.hasdata.com',
275+
url: endpoint,
276+
qs,
277+
body: method === 'POST' ? body : undefined,
278+
json: true,
279+
},
280+
);
272281

273282
const executionData = this.helpers.constructExecutionMetaData(
274-
this.helpers.returnJsonArray(response as IDataObject[]),
283+
this.helpers.returnJsonArray(responseData as IDataObject[]),
275284
{ itemData: { item: i } },
276285
);
277286
returnData.push(...executionData);

0 commit comments

Comments
 (0)